Question
problem with leaving from standby mode
Posted on July 26, 2013 at 12:06
Hi, i've got a problem with leaving from standby mode, both by RTC Alarm and WKUP pin. This is my code:
int main( void ) { #ifdef DEBUG debug(); #endif prvSetupHardware(); GPIOC->ODR |= (u16)0x0040; PWR_EnterSTANDBYMode(); GPIOC->ODR &= (u16)~0x0040; while (1) {}; } static void prvSetupHardware( void ) { RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE ); NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 ); NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); vLedInitialise(); vEXTI_Configuration(); vNVIC_Configuration(); vRTC_Configuration(); PWR_WakeUpPinCmd(ENABLE); } void vEXTI_Configuration( void ) { EXTI_InitTypeDef EXTI_InitStructure; /* Configure EXTI Line17(RTC Alarm) to generate an interrupt on rising edge */ EXTI_ClearITPendingBit(EXTI_Line17); EXTI_InitStructure.EXTI_Line = EXTI_Line17; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); } /*-----------------------------------------------------------*/ void vNVIC_Configuration( void ) { NVIC_InitTypeDef NVIC_InitStructure; /* Configure one bit for preemption priority */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); /*Enable the RTC Alarm Interrupt*/ NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQChannel; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); } /*-----------------------------------------------------------*/ void vRTC_Configuration( void ) { RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE); /* Allow access to BKP Domain */ PWR->CR |= 0x00000100; RCC_LSEConfig(RCC_LSE_ON); while (RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET) {} RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE); RCC_RTCCLKCmd(ENABLE); RTC_WaitForSynchro(); RTC_WaitForLastTask(); RTC_ITConfig(RTC_IT_ALR, ENABLE); RTC_WaitForLastTask(); RTC_SetPrescaler(32767); RTC_WaitForLastTask(); while ( RTC_GetFlagStatus( RTC_FLAG_SEC ) == RESET ) {} RTC_SetAlarm(5); RTC_WaitForLastTask(); } void RTCAlarm_IRQHandler( void ) { GPIOC->ODR ^= 0x00000080; EXTI_ClearITPendingBit(EXTI_Line17); if (PWR_GetFlagStatus(PWR_FLAG_WU) != RESET) PWR_ClearFlag(PWR_FLAG_WU); RTC_WaitForLastTask(); RTC_ClearITPendingBit(RTC_IT_ALR); RTC_WaitForLastTask(); } I know that EXTI isn't necessary to wake MCU up from standby mode, but I tried the same code with Stop Mode and it works. Another issue is strange operation with debugger (JLINK) connected to the eval board - with Stop mode I had to abort debug session, and reset MCU. In standby mode I tried with connected or disconnected debugger and it has never worked. Could anyone help me? Regards #stm32-standby-wake-rtc #wkup