程序中定时1s和10s有什么问题没有
BOOL volatile led_flag;
BOOL volatile flag_1s;
BOOL volatile flag_10s;
void Sys_10ms_Interrupt(void) //10ms中断函数
{
static volatile u16 led_timer = 0;
static volatile u16 count_timer = 0;
static volatile u16 count_timer2 = 0;
count_timer++;
flag_1s = 0;
if(count_timer%100 == 0)
{
flag_1s = 1; //1s定时
count_timer2++;
if(count_timer2 == 10)
{
flag_10s = 1; //10s定时
count_timer2 = 0;
}
}
led_timer++;
if(led_timer>10) //100ms 反转
{
led_flag =~led_flag;
led_timer = 0;
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>