2010-02-16 02:48 PM
Entering Sleep mode for STM32F103RBT6
2011-05-17 04:40 AM
hey guys, sorry about the simple question, I am a student and am still learning, any help would be greatly appreciated
2011-05-17 04:40 AM
Try looking at the ST Library code, typically in \Keil\ARM\RV31\LIB\ST\STM32F10x\stm32f10x_pwr.c
/******************************************************************************* * Function Name : PWR_EnterSTOPMode * Description : Enters STOP mode. * Input : - PWR_Regulator: specifies the regulator state in STOP mode. * This parameter can be one of the following values: * - PWR_Regulator_ON: STOP mode with regulator ON * - PWR_Regulator_LowPower: STOP mode with * regulator in low power mode * - PWR_STOPEntry: specifies if STOP mode in entered with WFI or * WFE instruction. * This parameter can be one of the following values: * - PWR_STOPEntry_WFI: enter STOP mode with WFI instruction * - PWR_STOPEntry_WFE: enter STOP mode with WFE instruction * Output : None * Return : None *******************************************************************************/ void PWR_EnterSTOPMode(u32 PWR_Regulator, u8 PWR_STOPEntry) { u32 tmpreg = 0; /* Check the parameters */ assert_param(IS_PWR_REGULATOR(PWR_Regulator)); assert_param(IS_PWR_STOP_ENTRY(PWR_STOPEntry)); /* Select the regulator state in STOP mode ---------------------------------*/ tmpreg = PWR->CR; /* Clear PDDS and LPDS bits */ tmpreg &= CR_DS_Mask; /* Set LPDS bit according to PWR_Regulator value */ tmpreg |= PWR_Regulator; /* Store the new value */ PWR->CR = tmpreg; /* Set SLEEPDEEP bit of Cortex System Control Register */ *(vu32 *) SCB_SysCtrl |= SysCtrl_SLEEPDEEP_Set; /* Select STOP mode entry --------------------------------------------------*/ if(PWR_STOPEntry == PWR_STOPEntry_WFI) { /* Request Wait For Interrupt */ __WFI(); } else { /* Request Wait For Event */ __WFE(); } } /******************************************************************************* * Function Name : PWR_EnterSTANDBYMode * Description : Enters STANDBY mode. * Input : None * Output : None * Return : None *******************************************************************************/ void PWR_EnterSTANDBYMode(void) { /* Clear Wake-up flag */ PWR->CR |= CR_CWUF_Set; /* Select STANDBY mode */ PWR->CR |= CR_PDDS_Set; /* Set SLEEPDEEP bit of Cortex System Control Register */ *(vu32 *) SCB_SysCtrl |= SysCtrl_SLEEPDEEP_Set; /* Request Wait For Interrupt */ __WFI(); }