2014-11-09 03:20 AM
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
2014-11-09 07:23 AM
STM32F0xx_StdPeriph_Lib_V1.1.0\Project\STM32F0xx_StdPeriph_Examples\PWR\PWR_CurrentConsumption\main.c
2014-11-09 08:19 AM
Dear clive1
It is bit confused to understandSo I found following example which worked for me and well understandvoid 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 MCUDoes systick timer interrupt Handler can wake up the MCU? ''SysTick_Handler''Any advice2014-11-10 12:41 AM
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.2014-11-10 09:18 AM
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.2014-11-10 09:33 AM
Dear guo,
Thanks for the replyI checked with PA0 with external interrupter but CPU does not wake upPlease advice2014-11-11 06:52 AM
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.
2016-12-23 06:26 AM
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