AnsweredAssumed Answered

Can LPTIM fire two different interrupts?

Question asked by diego peinado martin on Apr 26, 2018
Latest reply on Apr 26, 2018 by diego peinado martin

Hello all. My problem is as follows.

I would like to set an event in the future, lets say 950ms, at one specific point in the code. Then I would like to set the STM32L432 in Stop2 mode, wake up the MCU near the event, lets say at 750 ms so it can wake up another device, and then do the task at 950ms.

I thought that LPTIM can fire two interrupts, one related to HAL_LPTIM_CompareMatchCallback, and the other related to HAL_LPTIM_AutoReloadMatchCallback.

I setup an example to see how it would work.

In CubeMX I configure LPTIM1 as "Counts internal clock events", and choose LSE as the LPTIM1 clock mux. LSE frequency is 32768 Hz, and set div2 as preescaler. So each time interval is 61.035 us. In the setup I set "update at the end of the period" and software as trigger.

In the main function after setup all the peripherals, I call to HAL_LPTIM_TimeOut_Start_IT(&hlptim1, 65535, 16383);

So I set up the period as 65535, so the autoreload should occur at 4s, and the timeout to 16383, so the compare match event should occur at 1s.

I wrote a HAL_LPTIM_CompareMatchCallback, and a HAL_LPTIM_AutoReloadMatchCallback.

When I run the program I get the HAL_LPTIM_CompareMatchCallback called each 4 secs, and HAL_LPTIM_AutoReloadMatchCallback is never called. Strange behaviour because I though that CompareMatchCallback should be called at 1 sec.

 

I suppose that I made some mistakes and I have misconceptions as well, so please can anybody tell me what should I do to setup two events in the future so one of them is used to wake up the MCU, and the other to make some transmission to other device?

 

Thanks in advance, best regards.

Outcomes