cancel
Showing results for 
Search instead for 
Did you mean: 

Send periodic signals with stop 2 mode in between

diego peinado martin
Associate II
Posted on April 16, 2018 at 16:57

I have a stm32L432kc nucleo as a master of other device that communicates by RF with other devices, call it Tag. STM32L4 communicates with Tag by SPI. The Tag shall receive RF from other devices at well defined periodic intervals, so the STM32L4 has to put the Tag in RX state some ms before the signal has to be received. This can be done with help of one timer. When the first message is received (RX is on for a long period) then the clock is started with interrupts. When the ISR is called the timer is stopped, the reception is done, and after that the clock is started again. This is done in this way to prevent clock drifting accumulates and the synchronization is lost.

The problem arises when I want to optimize power consumption. I should put the SMT32L4 in stop2 mode between signals (I also put the Tag in deep sleep mode and I have to awaken it before the signal comes).

How can I do that?  do I have to use two timers, one for STM32 awakening and other to count for the period between incoming signals?

I have read that the LPTIM does not stop when being in stop 2 mode. Can I use this LPTIM to count for the period between two signals (around 500 ms), and the internal waking unit for awakening the stm32l4 some time earlier (for instance 450 ms)?

Anybody has any sugestion?

Thanks in advance, best regards.

4 REPLIES 4
Posted on April 16, 2018 at 17:08

I'd imagine you can just use the LPTIM, have it counting time in a maximal fashion (0 - 0xFFFF), read the count register and delta for elapsed time, and set a trigger point with the capture/compare register.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
diego peinado martin
Associate II
Posted on April 17, 2018 at 14:03

Thank you Clive. I have very limited experience in stm32 programming. I've used timers with HAL_TIM_PeriodElapsedCallBack(), but this problem seems to be more difficult. I would like to have a running clock and then put the Tag in RX, so when it receives a message it will generate an interrupt so a Timestap can be generated related to this reception, call it T1. Then read what was received and depending on what is read then calculate the time interval up to it has to be set in RX again, call it DT. T1 and DT are added, so I would have to setup a way to get an interrupt or other way to set the Tag in RX when the running clock gets T1+DT value. In between the Tag should be put in stop 2 mode.

How works the capture/compare register? It can be used to make something like that?

Thanks for your time, best regards.

Posted on April 17, 2018 at 17:15

>>How works the capture/compare register?

Basically you have

CNT = (CNT + 1) % 65536; // or just use uint16_t math

When (CNT == CCR1) you get an event

If the timebase is milliseconds, CCR1 = (CNT + 450) % 65536; parking the trigger point 450 ms into the future

Not tried implementing this on the L4 LPTIM, docs suggest it should be workable

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
diego peinado martin
Associate II
Posted on April 26, 2018 at 09:15

Hello, Clive, thanks again. I've been some days buried in other works :-). Sorry for the delay.