STM32F103 wake-up from stop mode

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

pepahajek
Posts: 5
Joined: Thu May 16, 2013 8:31 am

STM32F103 wake-up from stop mode

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F103 wake-up from stop mode

Post by Giovanni »

Not sure, I never used it. Are you sure that the CPU is supposed to wake up in that point?

Giovanni
pepahajek
Posts: 5
Joined: Thu May 16, 2013 8:31 am

Re: STM32F103 wake-up from stop mode

Post by pepahajek »

Regarding Application Note AN2629 http://www.st.com/st-web-ui/static/acti ... 171691.pdf
in STOP mode it is possible to wake up without system reset.
pepahajek
Posts: 5
Joined: Thu May 16, 2013 8:31 am

Re: STM32F103 wake-up from stop mode

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F103 wake-up from stop mode

Post 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
pepahajek
Posts: 5
Joined: Thu May 16, 2013 8:31 am

Re: STM32F103 wake-up from stop mode

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F103 wake-up from stop mode

Post 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
pepahajek
Posts: 5
Joined: Thu May 16, 2013 8:31 am

Re: STM32F103 wake-up from stop mode

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F103 wake-up from stop mode

Post by Giovanni »

So better report a bug :)

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: STM32F103 wake-up from stop mode

Post by Giovanni »

I fixed it in the repository (bug #412), the problem affected STM32F1/F4/L1.

Thanks for finding.

Giovanni
Post Reply