#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "usart.h"
#include "timer.h"
u8 num;
//定时器中断实验
extern u8 i;
int main(void)
{
delay_init(); //延时函数初始化
NVIC_Configuration(); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
uart_init(9600); //串口初始化为9600
LED_Init(); //LED端口初始化
TIM3_Int_Init(4999,7199);//10Khz的计数频率,计数到5000为500ms
while(1)
{
// LED0=!LED0;
// delay_ms(2000);
if(i<10)
{
// i=0;
for(num=0;num<10;num++)
{
LED0=0;
delay_ms(500);
LED0=1;
delay_ms(500);
}
}
if(i>10)
{
LED0=1;
TIM_Cmd(TIM3, DISABLE); //使能TIMx
}
}
}
|