cancel
Showing results for 
Search instead for 
Did you mean: 

Stop mode and clock configuration at wake up

Aurélien f
Senior
Posted on December 28, 2017 at 07:42

Hello,

I'm facing an issue i cannot figure out. I'm currently working on a stm32l073 and using the following RTOS : RIOT-OS. When i wake up from stop mode, UART seems to be desynchronized because wrong characters are displayed. 

I have noticed that when i'm decreasing system clock, AHB clock and ABP clock all is working fine. Am i doing something wrong or do i need to reconfigure clock in the interrupt that is waking up the CPU from stop mode (this a RTC interrupt) ? 

If you have any ideas about this issue, feel free to share your thoughts

Best regards,

Aur�lien

#stm32 #stop-mode #stm32l073
13 REPLIES 13
Posted on May 07, 2018 at 10:36

I'm not trying to print but am expecting a response back from a LoRa module... Before putting the MCU to sleep, I tell the module to sleep. When it times out it responds with an OK...

It is that OK that I never see as the UART connection seems to be lost. I was informed that with STOP mode that is what happens. 

Posted on May 07, 2018 at 13:14

Hi

Ivanov.Igor

‌,

Thanks for the tip... My problem has regressed to something more basic... I am suspending all my tasks which successfully gets me to sleep via the PreSleepProcessing function...

My problem is that my RTC wakeup does not wake up... I have seen however that if I trigger an external interrupt with the same priority then it does? Its currently at the same priority as the RTOS so it does not make sense to me

Posted on May 07, 2018 at 22:03

The priority of the interrupt plays no role AFAIK: it wakes up the CPU, sent asleep by WFI instruction. I have not ever tested or created the situation when one tries to issue WFI while any high priority interrupt is disabled but pending. Analyze your NVIC state by debugger just before the WFI instruction. Don't forget to force stopping any running timers when debugging: see DBGMCU unit, and avoid any communication processes that could trigger an interrupt (UART, I2C, etc...) when you stay at WFI.

Try to check if the RTC interrupt is really enabled at all, both in the RTC peripheral registers and in NVIC, and the RTC is really running (any crystal issues?).

By the way. You say, you deinit UART before getting asleep. First, it's not neccessary at all because UART consumes no power when its clock is stopped (STOP mode); second, as soon as the UART is deactivated, its assigned TX pin goes in some undefined output level about VCC/2 what can lead to the significant current consumption at a CMOS input attached to this pin. The state of the UART is preserved during the STOP mode; the only reason, why you obtained the garbage characters from the UART after waking up, is that the whole RCC must be reinitialized after the STOP mode; it's done by the call to SystemInit(). That all is my proved experience form the last month .

Posted on May 08, 2018 at 17:01

Thanks for that... that helped me a lot...

It seems to be timing related. If I put HAL_ResumeTick() in PostSleepProcessing() and add a break point to it. That little break, allows the code to call the RTC interrupt.

I'm confused... maybe what I am trying to do is not possible. My understanding was that STOP mode would only be interrupted by an external interrupt. I only have 2 of those- RTC and one used to receive pulses. Systeminit or restarting the clock does not seem to help.

The plan was to suspend all the devices, go to sleep, start the RTC timer at a time less than the sleep time and wake up. 

Then when the OK came back from the module I would send the next packet, go to sleep and repeat.

I'll keep playing around with different permutations... At least I have more tools when I am debugging.