AnsweredAssumed Answered

STM32F0 SLEEP MODE

Question asked by PA3040 on Nov 9, 2014
Latest reply on Dec 23, 2016 by Jaroslav Becka
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();}


}

Outcomes