LPC1768 / ARM Cortex-M3 microsecond delay

前端 未结 3 1901
闹比i
闹比i 2021-01-25 05:22

I\'m trying to implement a microsecond delay in a bare metal arm environment( LPC1768 ) / GCC. I\'ve seen the examples that use the SysTimer to generate an interrupt that then d

3条回答
  •  执笔经年
    2021-01-25 05:32

    One way is just to use a loop to create the delay, something like shown below. You need to calibrate your factor. A more general purpose approach is to calculate the factor on startup based on some known timebase.

    #define CAL_FACTOR ( 100 )
    
    void delay (uint32_t interval)
    {
      uint32_t iterations = interval / CAL_FACTOR;
    
      for(int i=0; i

提交回复
热议问题