Page 1 of 2
STM32F103 wake-up from stop mode
Posted: Thu May 16, 2013 8:50 am
by pepahajek
Hi,
I have a problem with the stop mode on STM32. What I need is to go to the Stop mode (or any suitable low power mode), after some time to wake-up CPU by RTC and continue code execution from the point where I went to Stop mode.
I use following code to go to the Stop mode
Code: Select all
/* going to anabiosis*/
PWR->CR |= (PWR_CR_PDDS | PWR_CR_LPDS | PWR_CR_CSBF | PWR_CR_CWUF);
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__WFI();
Waking-up by RTC works fine but the problem is that the code execution does not continue from the last point, CPU is reseted.
Re: STM32F103 wake-up from stop mode
Posted: Thu May 16, 2013 9:56 am
by Giovanni
Not sure, I never used it. Are you sure that the CPU is supposed to wake up in that point?
Giovanni
Re: STM32F103 wake-up from stop mode
Posted: Thu May 16, 2013 11:24 am
by pepahajek
Regarding Application Note AN2629
http://www.st.com/st-web-ui/static/acti ... 171691.pdfin STOP mode it is possible to wake up without system reset.
Re: STM32F103 wake-up from stop mode
Posted: Thu May 16, 2013 10:07 pm
by pepahajek
I have had a mistake in code which put it into STOP mode. See example here
http://tinyurl.com/d58szpu it uses EXTI line to waking up from stop mode.
My problem now is how to use RTC alarm as a EXTI line in order to wake up CPU.
Re: STM32F103 wake-up from stop mode
Posted: Fri May 17, 2013 7:55 pm
by Giovanni
The F1 RM states "EXTI line 17 is connected to the RTC Alarm event", I think all other models are similarly able to wakeup the core.
Giovanni
Re: STM32F103 wake-up from stop mode
Posted: Sat May 18, 2013 1:10 pm
by pepahajek
Here is a code
http://pastebin.com/mjskWx1t where a RTC Alarm is connected to the 17th EXTI line and is able to leave STOP mode. Use "sleep" command in shell to get to STOP mode.
Re: STM32F103 wake-up from stop mode
Posted: Sat May 18, 2013 1:20 pm
by Giovanni
Hi,
Thanks for the example, it will be useful. I don't understand why you redeclared the IRQ handler RTC_Alarm_IRQHandler in your application, is that because a problem in the EXT driver?
Giovanni
Re: STM32F103 wake-up from stop mode
Posted: Sat May 18, 2013 1:32 pm
by pepahajek
Look at the os\hal\platforms\STM32F1xx\ext_lld_isr.c there is an IRQ handle defined as
Code: Select all
CH_IRQ_HANDLER(RTCAlarm_IRQHandler) {
..
..
but in my opinion RTCAlarm_IRQHandler is wrong name for "RTC_Alarm_IRQHandler" (difference in one character) which is defined in os\hal\platforms\STM32F1xx\hal_lld_f103.h
Without my explicit definition of this IRQ handler it throws an unhandled exception.
Re: STM32F103 wake-up from stop mode
Posted: Sat May 18, 2013 1:43 pm
by Giovanni
So better report a bug

Giovanni
Re: STM32F103 wake-up from stop mode
Posted: Sat May 18, 2013 3:37 pm
by Giovanni
I fixed it in the repository (bug #412), the problem affected STM32F1/F4/L1.
Thanks for finding.
Giovanni