void Timer1_Delay1ms(volatile UINT32 u32CNT)
{
u32 i ;
clr_TR1; //Stop the Timer1
clr_T1M; //T1M=0, Timer1 Clock = Fsys/12
clr_TF1;
TMOD |= 0x10;
// i = u32CNT ;
//Timer1 is 16-bit mode
// set_TR1; //Trigger Timer1
//for(i=0;i<u32CNT;i++)
for(i=u32CNT;i>0;i--)
// while(i > 0)
{
clr_TR1; //Stop the Timer1
TL1 = LOBYTE(TIMER1_DIV12_VALUE_1ms);
TH1 = HIBYTE(TIMER1_DIV12_VALUE_1ms);
set_TR1; //Trigger Timer1
while (TF1 != 1); //Check Timer1 Time-Out Flag
clr_TF1;
// i --;
}
clr_TR1; //Stop the Timer1
}
for循环使用i--和i++的区别在哪里?i--减到0之后不会停止这个数变为0xffff继续减是怎么回事? |