cancel
Showing results for 
Search instead for 
Did you mean: 

How do I implement the overflow for an LPTIM in encoder mode in STOP2

christoph23
Associate II

Hi there,

I use an STM32L433 and have to evaluate a quadrature encoder in a battery device.

For this I want to use the LPTIM1 in encoder mode.

My problem is that the 16 bit of the timer is not enough to save the desired position.

As soon as there is an overflow, the controller has to wake up briefly to save the overflow.

How do I do that without the µC having to wake up (Stop2) very often? If I set the ARR to 0xFFFF and the CRR to 0x0000, I can correctly detect the overflow, but of course I have a problem if the quadrature signal jitters directly between 0xFFFF and 0x0000.

Has anyone of you already implemented something like this and solved it? This should actually be a standard problem.

Thank you for your answers.

2 REPLIES 2
TDK
Guru

You could set the counter to 0x8000 when the mcu wakes up to avoid update triggering immediately again.

If you feel a post has answered your question, please click "Accept as Solution".
christoph23
Associate II

I have already considered setting it to 0x8000. Unfortunately, I see no way to manipulate the counter value using software. The counter register is only readable in encoder mode. I can only reset via a control register.