将TIM2的周期配置成0.2ms。定时器周期公式:(1+TIM_Prescaler)/72M)*(1+TIM_Period)#defineNVIC_Priority_Timer21unsignedin
1.毫秒级的延时延时1ms;voiddelay_1ms(void){unsignedinti;for(i=1;i(unsignedint)(xtal*143-2);i++);}在上式中,xtal为晶振
将TIM2的周期配置成0.2ms。定时器周期公式:(1+TIM_Prescaler)/72M)*(1+TIM_Period)#defineNVIC_Priority_Timer21unsignedin
1.毫秒级的延时延时1ms;voiddelay_1ms(void){unsignedinti;for(i=1;i(unsignedint)(xtal*143-2);i++);}在上式中,xtal为晶振