最近做一个充电器单片机软件,涉及到用一个定时器设定多个定时器,而且要求其中一个响应后,关闭其他定时器,程序如下,上电跑了以后感觉没工作,请教下哪儿出问题了。
单片机定时器设定1ms溢出一次,中断如下:
oid TIMER1_Rpt(void) interrupt TIMER1_VECTOR
{
static unsigned char i;
i++;
if(i>=5)
{
i=0;
breath_light();
}
if(DELAY300MS_ON)
{
if(++Count.delay_time2 >= SOrder_300ms)
{
Count.delay_time2 = 0;
DELAY300MS_ON = 0;
LED_blink();
}
}
if(DELAY500MS_ON)
{
if(++Count.delay_time0 >= SOrder_500ms)
{
Count.delay_time0 = 0;
DELAY500MS_ON = 0;
Vol_relief( );
}
}
if(DELAY1S_ON)
{
if(++Count.delay_time1 >= SOrder_1s)
{
Count.delay_time1 = 0;
DELAY1S_ON = 0;
}
}
if(FLAG_1HOURHALF ==1)
{
if(++Count.Order_1min0 >= SOrder_1min)
{
Count.Order_1min0 = 0;
if(++Count.Order_1hour5 >= SOrder_1hour5)
{
Count.Order_1hour5 = 0;
FLAG_1HOURHALF = 0;
}
}
}
if(FLAG_2HOUR == 1)
{
if(++Count.Order_1min0 >= 20000) //SOrder_1min)
{
Count.Order_1min0 = 0;
if(++Count.Order_2hour >= SOrder_2hour)
{
Count.Order_2hour = 0;
FLAG_2HOUR = 0;
}
}
}
if(FLAG_7HOURHALF ==1)
{
if(++Count.Order_1min0 >= SOrder_1min)
{
Count.Order_1min0 = 0;
if(++Count.Order_7hour5 >= SOrder_7hour5)
{
Count.Order_7hour5 = 0;
FLAG_7HOURHALF = 0;
}
}
}
主函数部分调用程序如下:
switch(Scharge)
{
case Idle:
........
break;
case pre_Charging:
/*设定*/
FLAG_2HOUR = 1;
.....
/* if(2hour arrive) */
if(FLAG_2HOUR == 0)
{
RED_LIGHT = 1;
Scharge = Close_charge;
}
break;
case Charging:
/*7.5hour set */
FLAG_7HOURHALF = 1;
.....
/*7.5hour arrived*/
if(FLAG_7HOURHALF == 0)
{
.....
}
break;
|