AnsweredAssumed Answered

STM32L031 How to use TIM2 as a 32 bit 32MHz with a 200ms period counter

Question asked by Hugo Balette on Nov 14, 2017
Latest reply on Nov 15, 2017 by KIC8462852 EPIC204278916

Hi everyone,

I used to work on STM32F407VG to develop a micro-sec timing application.

I'm reading on multiple Digital GPIOs configured as input, and measuring elapsed time between rising edges arriving on different GPIOS input.

Using STM32F407, I was triggering systick counter when I got the first rising edge, reading systick value while new rising edges arrives, and stop it after 200ms elapsed.

 

To adapt micro-controller size/price to my application, I'm now using STM32L031, and I'm facing problems : I can't get a precise systick counter: If I'm setting up systick to toogle a pin every 1us, it isn't precise at all.

It works fine for toogle pin every 1ms, but it's loosing precision if I try to get 1us.

 

I'd like to use TIM2 as a 32bit 32MHz counter, with a period of 200ms, but I can't manage to configure it as a 32bit counter.

 

Would you have any idea to help me ?

 

Thanks for your time, and have a good day !

 

Balette

Outcomes