标题: stm32f103r6仿真计数器程序+Proteus [打印本页]

作者: hxw165290805    时间: 2020-7-9 22:41
标题: stm32f103r6仿真计数器程序+Proteus
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)



单片机源程序如下:
#include "stm32f10x.h"
#include "Delay.h"
#include "smg.h"
#include "sys.h"
#include "timer.h"
#include "led.h"
#include "fmq.h"
#include "key.h"
#include "stm32f10x_tim.h"
uint16_t table[] = {
/*   0,    1,    2,    3,    4,     5,   6,    7,    8,     */  

0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F,   

/*   9,    A,    B,    C,    D,    E,    F,    .,  none    */  

0x6F, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71, 0x80, 0x00  

};
uint16_t t;
uint16_t  num[3],inc = 0x00;
int main(void)
{
         SMG_Init();
        GPIO_Write(GPIOA, 0x3f3f);
        GPIO_Write(GPIOB, 0xff3f);
        while (1)
        {
                t=KEY_Scan_KEY_INC();                //得到键值
          if(t)   //if(条件)t!=0真
                {
                         inc++;
                         if(inc <= 0xff)
                         {
                                  num[2]=inc%10;
                                  num[1]=inc/10%10;
                                  num[0]=inc/100;
                                        GPIO_Write(GPIOB,((~inc) <<8) + table[num[2]]);
                                        GPIO_Write(GPIOA,(table[num[1]] <<8) + table[num[0]]);
                         }
                         else
                         {
                                 inc = 0xff;
                         }
                }
        }
}

全部资料51hei下载地址:
work1.7z (232.98 KB, 下载次数: 137)

作者: zync    时间: 2020-12-29 13:04
不用连在一起吗
作者: 51hei团团    时间: 2021-1-9 18:57
zync 发表于 2020-12-29 13:04
不用连在一起吗

是用总线连在一的,单片机都是这样连的哦,用Proteus8.8仿真可以打开,如图:

51hei.png (26.68 KB, 下载次数: 78)

51hei.png





欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1