Page 1 of 1

"Dirty" stop of the RTOS and entering deep sleep mode

Posted: Mon Feb 16, 2015 8:37 pm
by gicho
In my application I have to stop the microcontroller (STM32F4) in deep sleep mode. Then it will be woken by edge on SYS WKUP pin (this is equivalent to reset - that's why I don't care about "clean" stop of the RTOS - I don't need to "re-start" after sleep).
I have implemented the steps to stop all drivers and threads, then chSysDisable (like in http://www.chibios.org/dokuwiki/doku.php?id=chibios:howtos:stop_os). But still whenever I call __WFI() (or __WFI() ) my code doesn't stop - neither in debug nor in release.
This is the last part of my code:

Code: Select all

  
  PWR->CSR |= PWR_CSR_EWUP;
  /* Clear Wake-up flag */
  PWR->CR |= PWR_CR_CWUF;
  /* Select STANDBY mode */
  PWR->CR |= PWR_CR_PDDS;
  /* Set SLEEPDEEP bit of Cortex System Control Register */
  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
  __DSB();
  /* Request Wait For Interrupt */
  __WFI();
  __WFE();


But the CPU doesn't stop at the WFI (or WFE) instructions ...

In the context of all this, could somebody recommend how to "stop" the CPU effectively?

Re: "Dirty" stop of the RTOS and entering deep sleep mode

Posted: Mon Feb 16, 2015 8:43 pm
by Giovanni
Hi,

Search the forum because somebody already posted a solution, also look at the RTC demos.

Giovanni

Re: "Dirty" stop of the RTOS and entering deep sleep mode

Posted: Tue Feb 17, 2015 6:33 pm
by gicho
Thank you, I will look for this information.