AnsweredAssumed Answered


Question asked by Martin Guthrie on Jan 30, 2017
Latest reply on Feb 3, 2017 by Khouloud G

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...