一、protues画出流水灯图架
1.项目工程的创建
- 打开软件,点击new project。
- 选择工程创建的位置,我直接默认位置。
- next之后,选择一个空板
- 继续next,选不创建PCB
- 还是next,选择创建Firmware Project,选择芯片(如图所示)
- next之后就是finsh。
2.画图
至于怎么操作,推荐看这篇博客。Proteus实现简单51程序的设计与仿真
二、程序的实现
程序的仿真用的是keil5。
一定要勾选Create HEX File(在output里面)。
C++里面的路径一定要准确
可以看到编译和重编译都没问题,可以下载程序进行仿真调试了,我这里出了一个问题——找不到仿真器。
即使我下载了这些仿真器但是在设备管理里面都没有找到,目前还在解决中,不过程序应该没什么问题,下载就可以用。
源代码
#include "stm32f10x.h"
GPIO_InitTypeDef GPIO_InitStructure;
void delay_ms(uint32_t ms)
{
uint32_t i_cnt, j_cnt;
for (i_cnt = 0; i_cnt < 3000; i_cnt++);
for (j_cnt = 0; j_cnt < ms; j_cnt++);
}
uint32_t i;
int main(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIOA->BSRR = 0xff;
while (1)
{
for (i = 0; i < 8; i++)
{
delay_ms(99000);
GPIOA->BRR = (1 << i);
delay_ms(99000);
GPIOA->BSRR = (1 << i);
}
for (i = 0; i < 8; i++)
{
delay_ms(99000);
GPIOA->BRR = 0x000000ff;
delay_ms(99000);
GPIOA->BSRR = 0x000000ff;
}
}
}
效果演示
没有解决仿真器的问题,目前还无法展示。
三、小结
在keil5中进行仿真的时候,文件路径一定要对,不然错误百出