STM32延時函數(shù)分析
由于fac_ms基數(shù)為9000 所以假設(shè)nms=1則 倒計時時間9000/9M=0.001s=1ms就是延時1ms
所以最大定時時間 T=2^24/9000=1864ms
延時實例:
while(1)
{
LED0=0;
delay_ms(500);
LED0=1;
delay_ms(500);
}


改變最大延時方法: 降低PLL倍頻,計算得到系統(tǒng)新頻率.


改變最大延時方法: 降低PLL倍頻,計算得到系統(tǒng)新頻率.
int main(void)
{
Stm32_Clock_Init(4);
delay_init(32);
led_init();
while(1)
{
LED0=0;
delay_ms(3000);
LED0=1;
delay_ms(3000);
}
}


此時最大延時 由于SYSCLK=32M 所以Systick=4M 既fac_ms=4000
Tmax=2^24/4000=4194ms
如果設(shè)置超過4194發(fā)生溢出,定時就不準(zhǔn)了
例子:


參考文獻(xiàn):<<例說STM32>>
<>


此時最大延時 由于SYSCLK=32M 所以Systick=4M 既fac_ms=4000
Tmax=2^24/4000=4194ms
如果設(shè)置超過4194發(fā)生溢出,定時就不準(zhǔn)了
例子:
int main(void)
{
Stm32_Clock_Init(4);
delay_init(32);
led_init();
while(1)
{
LED0=0;
delay_ms(4200);
LED0=1;
delay_ms(4200);
}
}

參考文獻(xiàn):<<例說STM32>>
<
評論