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.

MSP432E401Y: wake up from hibernation with RTC match

Part Number: MSP432E401Y

Hello, 

I am trying to wake up from hibernation with RTC match and wake up pin. The MSP432 can wake up with pin but not with RTC.  Here the part of code that configures hibernation and to enter hibernation. I think I am forgetting some configuration line but I don't know which one.

__attribute__((optnone)) Public void CtrlHibernateInit(void)
{
    /* Enable the the Hibernate module and wait for it to be ready */
    SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

    /* If first start up, enable hibernate
     * and RTC.
     */
    if (HibernateIsActive() == FALSE) {
        HibernateEnableExpClk((uint32)CPU_FREQUENCY);

        HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC);

        HibernateRTCEnable();
        HibernateCounterMode(HIBERNATE_COUNTER_RTC);
        HibernateRTCSet(0);
    }
}



__attribute__((optnone, noreturn)) Public void CtrlHibernateDoHibernate(void)
{
    /*
     * Read and clear any status bits that might have been set since
     * last clearing them.
     */
    uint32 hibIntStatus = HibernateIntStatus(FALSE);
    HibernateIntClear(hibIntStatus);

// wake up each 30 seconds
    HibernateRTCMatchSet(0, HibernateRTCGet()+30);
    HibernateRequest();

    for (;;) {
        /* Spin for a while for hibernate to activate. */
        __NOP();
    }
}

  • Hi,

      I don't see you call MAP_HibernateWakeSet(HIBERNATE_WAKE_RTC) to enable interrupt for RTC wake.  I will suggest you look at the example at C:\ti\simplelink_msp432e4_sdk_4_20_00_12\examples\nortos\MSP_EXP432E401Y\driverlib\hibernate_vdd3on_rtcwake. This example uses RTC to wakeup from hibernate. 

  • hi, line 12.. I am using this example with modifications

  • ok. 

    I just tried the hibernate_vdd3on_rtcwake example as-is and it is working for me. It will wake up after 5 seconds once I press the SW1 switch to put the device in hibernate mode. Why don't you try the example without modification first on the LaunchPad and then on your custom board? Can you get the example to work? If you can get the example working then you can compare it with your modified code. You can also try your own code on the LaunchPad too. Does it work on the LaunchPad? Check if you have valid 32.769kHz XOSC signal to the device. 

  • Hi, 

    I have tested on the launchpad and it works fine. But I need to modify the code to use without IRQ, only wake up by RTC and go to main. is it possible?

  • Hi,

    But I need to modify the code to use without IRQ,

      That is not possible. When the device is in hibernate mode, all clocks are stopped except the RTC. This means the CPU is in idle. You must generate an interrupt in order to wake up the clocks and the CPU. The RTC match generates an IRQ to the processor to wake up the device. 

  • I have modified the code and it works without IRQ. But I am trying to move it to our system and it does not work.... I have to investigate more what's going on....

    /* DriverLib Includes */
    #include <ti/devices/msp432e4/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    
    void delay(uint32_t delay_ms) // assumes 1 ms tick.
    {
    uint32_t start = 0;
    
    while (start < delay_ms) {
        start++;// nop
    }
    }
    
    int main(void)
    {
        uint32_t systemClock;
        uint32_t hibIntStatusRaw = 0u;
    
        /* Configure the system clock for 120 MHz */
        systemClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ | SYSCTL_OSC_MAIN |
                                              SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480),
                                              120000000);
    
        /* Enable the clock to the GPIO Port N and wait for it to be ready */
        MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
        while(!(MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_GPION)))
        {
        }
    
        /* Configure the GPIO PN0-PN1 as output and switch it LED D2 ON */
        MAP_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, (GPIO_PIN_0 | GPIO_PIN_1));
        MAP_GPIOPinWrite(GPIO_PORTN_BASE, (GPIO_PIN_1), 0);
        delay(12000000);
    
        /* Enable the clock to the Hibernate and wait for it to be ready */
        MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
        while(!(MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_HIBERNATE)))
        {
        }
    
        /* Configure Hibernate for VDD3ON Mode with Pin Wakeup if Hibernate
         * module has not been configured */
       if(!MAP_HibernateIsActive())
        {
            MAP_HibernateEnableExpClk(systemClock);
            MAP_HibernateWakeSet(HIBERNATE_WAKE_RTC | HIBERNATE_WAKE_PIN);
            MAP_HibernateRTCSet(0);
            MAP_HibernateRTCEnable();
        }
       else {
           hibIntStatusRaw = MAP_HibernateIntStatus(true);
           MAP_HibernateIntClear(hibIntStatusRaw);
           if ((hibIntStatusRaw & (HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_RTC_MATCH_0)) != 0u) {
               MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, GPIO_PIN_1);
               delay(12000000);
           }
       }
    
        MAP_HibernateRTCMatchSet(0, (MAP_HibernateRTCGet()+5));
        MAP_HibernateRequest();
    
        while(1)
        {
        }
    }