Skip to main content
pbdiazam
Associate II
November 1, 2018
Question

STM32L0 - Microseconds delay function

  • November 1, 2018
  • 3 replies
  • 824 views

Hi everyone!

I am using a STM32L0 board and I need to read data from a sensor. To be able to do this, I need a microsecond delay function, but I could not find any way to achieve this.

I need some help! Thank you!

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    November 1, 2018

    Free run a TIM at 1 MHz (or higher) and delta the count measurement until it reaches the span of the delay required. Pretty basic stuff.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Dvorak.Peter
    Associate II
    November 2, 2018

    True, unless you need low microseconds. Here I would use inline asm counter code or insert NOPs

    Tesla DeLorean
    Guru
    November 2, 2018

    If you need nano-second realm stuff clock the TIM faster. Heck even at 24 MHz you can get well sub-microsecond

    On the non-CM0 parts consider the DWT_CYCCNT

    Timer and counters aren't afflicted by interrupt loading compared to fixed iterations loops with NOP, etc.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..