Question
RTC Wakeup doesn't after sleep
Posted on October 15, 2014 at 19:38
I'm trying to wakeup the processor after it has been put to sleep by the _wfe instruction via the RTC wakeup event.
It is not working for me. There are no examples of WFE wakeup in the library projects that I can find. The processor does wake up if I type a character as the UART Rx interrupt is still enabled and it wakes up on CAN activity. Here is my sleep procedure, you will notice that there are a couple of FreeRTOS associated calls:start_wakeup_timer( 60 ); // 1 minutes for testing purposes
CAN_OperatingModeRequest( CAN1, CAN_OperatingMode_Sleep );
CAN_Sleep( CAN1 );
disable_system_timer(); // shutdown the high speed tick
portNVIC_SYSTICK_CTRL_REG &= ~portNVIC_SYSTICK_ENABLE_BIT;
__asm volatile( ''cpsid i'' );
SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
__asm volatile( ''dsb'' );
__asm volatile( ''sev'' );
__asm volatile( ''wfe'' );
__asm volatile( ''wfe'' );
__asm volatile( ''isb'' );
SCB->SCR &= ~SCB_SCR_SEVONPEND_Msk;
/* Re-enable interrupts. */
__asm volatile( ''cpsie i'' );
/* Restart SysTick. */
portNVIC_SYSTICK_CTRL_REG |= portNVIC_SYSTICK_ENABLE_BIT;
void start_wakeup_timer( uint16_t wakeup_seconds )
{
RTC_WakeUpCmd( DISABLE );
RTC_SetWakeUpCounter( wakeup_seconds );
RTC_ClearITPendingBit( RTC_IT_WUT );
RTC_ITConfig( RTC_IT_WUT, ENABLE );
RTC_WakeUpCmd( ENABLE );
RTC_ClearFlag( RTC_FLAG_WUTF );
}
RTC_powerup is called during the reset procedure
bool RTC_Config(void)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
RCC_BackupResetCmd( ENABLE );
RCC_BackupResetCmd( DISABLE );
PWR_BackupAccessCmd(ENABLE);
RCC_LSEConfig(RCC_LSE_ON);
while(RCC_GetFlagStatus(RCC_FLAG_LSERDY) == RESET);
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSE);
return RTC_WaitForSynchro();
}
void RTC_powerup( void )
{
RTC_InitTypeDef RTC_InitStructure;
RTC_DateTimeTypeDef dateTime;
RTC_Config();
RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
RTC_InitStructure.RTC_SynchPrediv = 0xFF;
RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
RTC_Init(&RTC_InitStructure;
set_date_time( &dateTime, false );
RTC_WakeUpCmd( DISABLE );
RTC_WakeUpClockConfig( RTC_WakeUpClock_CK_SPRE_16bits );
}
What am I missing?
Thanks,
Vance
#sleep #timer #stm32 #rtc #wfe #wakeup