cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 SLEEP MODE

pic_micro
Associate II
Posted on November 09, 2014 at 12:20

Dear All

My following program blinks the LED using systick timer,while after ten times blink the LED the MCU should goes to sleep mode please advice to configure sleep method

#include 'stm32f0xx.h'
#include 'stm32f0xx_tim.h'
#include <stm32f0xx_rcc.h>
volatile uint32_t msTicks;

void gpio_init(){
 
 GPIO_InitTypeDef GPIO_InitStructure;
 RCC_AHBPeriphClockCmd (RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOA,ENABLE);
 RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
 
 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_8 ; 
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; 
 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
 GPIO_Init(GPIOC, &GPIO_InitStructure); 
 
}

void blink_LED(){
 if (msTicks == 1000){GPIOC->ODR ^= GPIO_Pin_8; msTicks = 0;}
 
}

void SysTick_Handler (void) {
 msTicks++; // Increment counter
}
int main(){
 SysTick_Config (SystemCoreClock/1000); // Configure the SYSTICK
 gpio_init();
 while(1){blink_LED();}
 
 
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

#sleepmode #low-power #stm32f0
7 REPLIES 7
Posted on November 09, 2014 at 16:23

STM32F0xx_StdPeriph_Lib_V1.1.0\Project\STM32F0xx_StdPeriph_Examples\PWR\PWR_CurrentConsumption\main.c

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pic_micro
Associate II
Posted on November 09, 2014 at 17:19

Dear clive1

It is bit confused to understand

So I found following example which worked for me and well understand

void PWR_EnterSTANDBYMode(void){

  PWR->CR |= PWR_CR_CWUF; /* Clear Wakeup flag */

  PWR->CR |= PWR_CR_PDDS; /* Select STANDBY mode */

  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; /* Set SLEEPDEEP bit of Cortex-M0 System Control Register */

  __WFI(); /* Request Wait For Interrupt */

}

This codes MCU gets standby mode but still I can not wake up the MCU

Does systick timer interrupt Handler can wake up the MCU?  ''SysTick_Handler''

Any advice

lo_529
Associate III
Posted on November 10, 2014 at 09:41

On STM32F1xx, normal interrupt can't wakeup CPU from standby mode. Almost not on other STM32Fxxx.

You need to check the RM for the detail info of low power mode.

Posted on November 10, 2014 at 18:18

STANDBY turns the part off, it exits via a reset, and a limited subset of signals can wake it and cause it to reset in this fashion.

General IRQs will not wake the part, perhaps you are thinking of other low power modes, please review the Reference Manual, et al.

It should be possible to use a low power mode that can loop a WFI in the idle task, and the processor will service the interrupt(s) as they arrive, elevate tasks, before iterating another WFI.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pic_micro
Associate II
Posted on November 10, 2014 at 18:33

Dear guo,

Thanks for the reply

I checked with PA0 with external interrupter but CPU does not  wake up

Please advice

pic_micro
Associate II
Posted on November 11, 2014 at 15:52

Dear clivel thanks for the reply and I found following info

Figure 2.20. WFI instruction in Thumb state

WFI (Wait For Interrupt) makes the processor suspend execution (Clock is stopped) until one of the following events take place:

  • An IRQ interrupt

  • An FIQ interrupt

  • A Debug Entry request made to the processor.

But I configured external interrupt ( PA0) it seem to be CPU does not wake up

please advice

Jaroslav BECKA
ST Employee
Posted on December 23, 2016 at 15:26

Hello

The STM32F0 can be woken-up from STANDBY mode by a few special WKUP pins (rising edge), IWDG reset, external reset on NRST pin, RTC alarm.

For the SLEEP mode any interrupt can wake-up the device.

I would recommend you to download the standard peripheral library package for STM32F0:

http://www.st.com/en/embedded-software/stsw-stm32048.html

 

and check the PWR examples ...\STM32F0xx_StdPeriph_Lib_V1.5.0\Projects\STM32F0xx_StdPeriph_Examples\PWR