cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_LPTIM_ReadCounter

Martin Guthrie
Associate
Posted on January 30, 2017 at 18:08

I am using the STM32L476 LPTIM1 and using HAL_LPTIM_ReadCounter() and I was getting unexpected results. 

The reference manual (RM0351 June 2016) section 30.7.8 says that the CNT register must be read twice and only if the same value is read two times in a row is the result valid.  The unexpected result resolved itself when I implemented this logic.

Why doesn't the HAL API HAL_LPTIM_ReadCounter() follow the reference manual?

I also had problems consistently having the callback HAL_LPTIM_AutoReloadMatchCallback() be called every time LPTIM interrupt occurred.  Some percentage of the time this callback was not called, despite the fact that in HAL_LPTIM_Counter_Start_IT() the ARRM bit is ALWAYS set.  To fix this problem, I created a flag in LPTIM1_IRQHandler() and if the callback was not called, I called it myself.  This fixed my problem.  Why was this necessary?

It seems to me, between these two observations, that there is an issue setting LPTIM registers that the HAL LPTIM api is not dealing with...

1 REPLY 1
Khouloud GARSI
Lead II
Posted on February 03, 2017 at 10:29

Hello

Guthrie.Martin

,

I agree that the implementation should be aligned with the reference manual. I will report your feedback internally to our HAL team for further investigation.

Thanks a lot for highlighting this.

Regarding the second point, for more debug, I need the frequency and the configuration you have opted for when using the LPTIM peripheral.

Khouloud.