It RTC match wake-up can work for hundreds of times in row then inexplicably stop waking up. It will always wake from a low on the wake pin.
The hardware has the VBAT pin tied directly to the VDDA - VDD4 pins and set to 3.3V, The 3.3V power supply is always on.
The HIB pin is pulled up and can be monitored to verify that the processor is in hibernation.
Please let me know what am I doing wrong, if anything?
Thanks
Here's the power-on code: ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
UINT32 ui32Status = 0;
RTC_time_t timeDate, timeDateTst;
volatile timeStamp_t timeStamp;
// Check to see if Hibernation module is already active, which could mean
// that the processor is waking from a hibernation.
if( ROM_HibernateIsActive() )
{
// Read the status bits to see what caused the wake.
// Clear the wake source so that the device can be put into hibernation again.
ui32Status = ROM_HibernateIntStatus( 0 ); // Get raw interrupt status
ROM_HibernateIntClear( ui32Status );
if( ui32Status & HIBERNATE_INT_RTC_MATCH_0 ) // Wake was due to RTC match.
{
INFO( "Wake Due To: RTC TIMEOUT" );
}
else if( ui32Status & HIBERNATE_INT_RESET_WAKE ) // Wake was due to Sys Reset
{
INFO( "Wake Due To: RESET" );
}
else if( ui32Status & HIBERNATE_INT_PIN_WAKE ) // Wake was due to the External Wake pin.
{
INFO( "Wake Due To: WAKE PIN" );
}
else if( ui32Status & HIBERNATE_INT_GPIO_WAKE ) // Wake was due to GPIO wake.
{
INFO( "Wake Due To: GPIO WAKE" );
}
}
else // Hibernation module not active, so set it up
{
ROM_SysCtlPeripheralEnable( SYSCTL_PERIPH_HIBERNATE );
// Configure the module clock source.
ROM_HibernateEnableExpClk( ROM_SysCtlClockGet() );
ROM_HibernateClockConfig( HIBERNATE_OSC_HIGHDRIVE );
vTaskDelay( MS_TO_TICKS(1500) ); // Allow time for the crystal to power up.
ROM_HibernateRTCEnable(); // Enable RTC mode.
HWREG( HIB_CTL ) |= HIB_CTL_VDD3ON;
while( !(HWREG(HIB_CTL) & HIB_CTL_WRC) ); // Wait until the write complete bit is set.
INFO( "Hib Module Initialized" );
}
// If the wake was not due to the above sources, then it was a system reset.
if( !(ui32Status & (HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_RTC_MATCH_0 |
HIBERNATE_INT_GPIO_WAKE | HIBERNATE_INT_RESET_WAKE)) )
{
INFO( "Wake Due To: SYSTEM RESET" ); // This was a system restart, not wake from hibernation.
}
ROM_HibernateDataGet( (uint32_t *)&hibData, HIB_DATA_MAX_NUM_WORDS ); // Read the battery backed memory
Here's the hibernation entry code: -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void setRTCIntervalWakeupAlarm( UINT32 wakeUpSeconds )
{
timeStamp_t RTCSeconds, matchSeconds; // (NOTE: timeStamp_t is a UINT32)
UINT32 ui32Status;
// Save hibernation data in battery backed RAM for next power-on wake
ROM_HibernateDataSet( (uint32_t *)&hibData, HIB_DATA_MAX_NUM_WORDS );
RTCSeconds = RTC_get_timeStamp();
matchSeconds = RTCSeconds + wakeUpSeconds;
HibernateRTCMatchSet( 0, matchSeconds ); // Set the match 0 register for wakeUpSeconds seconds from now.
ui32Status = ROM_HibernateIntStatus( 0 ); // Clear any pending status
ROM_HibernateIntClear( ui32Status );
while( HibernateRTCMatchGet(0) != matchSeconds )
{
HibernateRTCMatchSet( 0, matchSeconds ); // Set the match 0 register for wakeUpSeconds seconds from now.
INFO( "ERROR: RTCMatchGet" );
}
HibernateWakeSet( HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC );
while( (HibernateWakeGet() & (HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC)) != (HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC) )
{
HibernateWakeSet( HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC );
INFO( "ERROR: RTCWakeGet" );
}
INFO( "CurrTime = %lu RTCMatchSet = %lu", RTCSeconds, matchSeconds );
vTaskDelay( MS_TO_TICKS(50) ); // Wait for INFO message to print out
IntMasterDisable();
HWREG( HIB_CTL ) |= HIB_CTL_HIBREQ; // Request hibernation.
while( TRUE );
}
//------------------------------------------------------------------------------------------------------------------------
timeStamp_t RTC_get_timeStamp( void )
{
timeStamp_t ulRTC1, ulRTC2, ulRTCSS1, ulRTCSS2;
IntMasterDisable();
do
{
ulRTC1 = HWREG( HIB_RTCC );
ulRTCSS1 = HWREG( HIB_RTCSS );
ulRTCSS2 = HWREG( HIB_RTCSS );
ulRTC2 = HWREG( HIB_RTCC );
} while( (ulRTC1 != ulRTC2) || (ulRTCSS1 != ulRTCSS2) );
IntMasterEnable();
return( ulRTC2 ); // Return current time stamp
}