2018-11-01 08:08 AM
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!
2018-11-01 08:31 AM
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.
2018-11-02 06:29 AM
True, unless you need low microseconds. Here I would use inline asm counter code or insert NOPs
2018-11-02 07:57 AM
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.