单片机的实现多任务程序(8)
时间:2025-04-04
时间:2025-04-04
在51单片机如何实现多任务的程序
if (( Move_Num == 1 ) && ( CDis_Flag ))
XiSu_Dian = 1;
for ( i = 0;i < 20; i++);
Shi_bit = 1;
Ge_bit = 0;
Shu_Ma_Data = Led_Byte[SMG_Value[0]];
if (( Move_Num == 0 ) && ( CDis_Flag ))
XiSu_Dian = 1;
for ( i = 0;i < 20; i++);
Ge_bit = 1;
}
// 将主程序里面延迟时间在该子程序里面减去 循环时间 void Delay_Sub1(void)
{
if(Key1_Delay1 > Add_Ms)
Key1_Delay1 -= Add_Ms;
else
Key1_Delay1=0;
if(Key2_Delay1 > Add_Ms)
Key2_Delay1 -= Add_Ms;
else
Key2_Delay1=0;
if(Key3_Delay1 > Add_Ms)
Key3_Delay1 -= Add_Ms;
else
Key3_Delay1=0;
if( Key1_Flag2 == 1)
Key1_Delay2 += Add_Ms;
if( Key2_Flag2 == 1)
Key2_Delay2 += Add_Ms;
if( Key3_Flag2 == 1)
Key3_Delay2 += Add_Ms;
Add_Ms = 0;
}