-
Proteus中STM32F103R6的仿真计数器程序
资源介绍
m32f103r6仿真计数器程序+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;
}
}
}
}