This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

tm4c123 sometimes doesn't wake up from sleep using RTC

Hi

I am trying to wake up from sleep after 4 seconds using RTC timer

This code is working and wake from sleep after 4 second but after same time  it doesn't wake up from the sleep

changing the GPIO is waking the process and it continue to work

THE CODE

.

void HibernateHandler(void)
{
uint32_t ui32Status;
//
// Get the interrupt status and clear any pending interrupts.
//
ui32Status = HibernateIntStatus(1);
HibernateIntClear(ui32Status);
//
// Process the RTC match 0 interrupt.
//
if(ui32Status & HIBERNATE_INT_RTC_MATCH_0)
{
RTCTimeout=true;
//
// RTC match 0 interrupt actions go here.
//
}
}

.

.
ROM_SysCtlDeepSleepClockSet(SYSCTL_DSLP_DIV_1 | SYSCTL_DSLP_OSC_INT30|SYSCTL_DSLP_PIOSC_PD); // Set deep sleep clock to be main OSC divided by 1 -> 16Mhz crystal
// ROM_SysCtlDeepSleepPowerSet(SYSCTL_FLASH_LOW_POWER|SYSCTL_LDO_SLEEP|SYSCTL_TEMP_LOW_POWER|SYSCTL_SRAM_LOW_POWER) ; //
ROM_SysCtlPeripheralDeepSleepEnable(SYSCTL_PERIPH_GPIOC);//emergency switch port intrerrupt enable during sleep
// peripherals in sleep mode

ROM_SysCtlPeripheralClockGating(true);
RTCTimeout=false;
HibernateRTCMatchSet(0, HibernateRTCGet() + 4);

//
// Set up interrupts on the Hibernation module to enable the RTC match
// 0 interrupt. Clear all pending interrupts and register the
// interrupt handler.
//
HibernateIntRegister(HibernateHandler);
HibernateIntClear(HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_LOW_BAT |
HIBERNATE_INT_RTC_MATCH_0);
HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0);
HibernateIntClear(HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_LOW_BAT |
HIBERNATE_INT_RTC_MATCH_0);


if(!RTCTimeout)
//enter deepsleep mode
ROM_SysCtlDeepSleep(); //enter deep sleep mode

...

..

  • Hello Zahiz,

    Note that the RTC is counting ahead of 4 seconds. So the next match has to be set at the current count + 4 Second for subsequent wakeup.

    Regards
    Amit
  • Hi Amit,
    I think that is wat I am doing you can see in the code
    HibernateRTCMatchSet(0, HibernateRTCGet() + 4);
    the problem is that it is working for some time and then stopes

    thanks
    Zahi
  • Hello Zhai,

    So it is not just one time, but it may work for some time and then stop.

    1. Call HibernateRTCMatchSet(0, HibernateRTCGet() + 4); before going to deep sleep so that it is the last activity done
    2. Store the last match in the Hibernate Data Register so that when it fails we can check against the last working value and current match.

    Regards
    Amit
  • Hi
    still having the same problem
    once every 1000 or more time the processor doesn't wake from sleep
    I added also wake from switch so when I see that it is not working I press the button but it doesn't help
    when it is not working I can see that the 16MHz clock is working also the 32 kHz is working
    the power consumption is around 5mA but the processor is not working
    normal power when the processor is working is around 15mA
    in sleep around 1 mA

    thanks

    Zahi

  • Hello Zahi,

    Can you please share the CCS project (zip the project and attach it on the forum) for review?

    Regards
    Amit
  • Hi

     I attached zip file of the project, in the main.c file you can find the configuration of the peripherals (hibernate,  watchdog..) and the function/interrupt of the hibernate match RTC.

    You can also stop working with the watchdog by comment " #define __WD_ON".

    In this project the micro enter to deep sleep end wake up every 1 second, I turn on led before entering to deep sleep and turn it off when exit from deep sleep.

    After couple of minutes the micro stuck (the 16MHz and 32KHz are on), if I enable the watchdog (uncomment  " #define __WD_ON") the micro get reset from watchdog.

     thanks

    Zahi

     

    DeepSleep.zip

  • Hello Zahi,

    I ran the code for 30 minutes and it did not get stuck. I had made changes for some part of the code to map it to a TM4C123 launchpad (led pins, removing the for loop of 0x02000000, and removing the excessive use of ROM_HibernateIntClear). Also I removed the define for WD_ON and my IDE is CCS and not IAR.

    As for a trial experiment change the

    HibernateRTCMatchSet(0, Time2 + 1);

    to

    HibernateRTCMatchSet(0, Time2 + 2);

    Regards,
    Amit