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.

CCS/MSP432E401Y: HOW TO SET THE WAKEUP TIME FOR SLEEP IN MSP432E401Y ?

Part Number: MSP432E401Y

Tool/software: Code Composer Studio

Hi,

I want my system to woke up every one hour once and do the assigned task and again with no time(as soon as task completion) wants to go for deep sleep mode.

Can you please suggest me how to do it, with the functions defined in sdk _ 2_30_00_14?

Thank you!!!,                                                                                        

Bindu

  • Hello Bindu,

    Can you confirm if you want the MSP432E4 to go to deep sleep or Hibernate? There are examples that demonstrate both these features. These examples are "sleep_modes" and "hibernate" and are located in the folder: ./examples/nortos/MSP_EXP432E401Y/driverlib/

    Please note that these are non-RTOS based examples. We currently don't have RTOS based examples for these features. If you are interested in RTOS based example, please let us know.

    Thanks,
    Sai
  • Hello Sai ,

    I need to put the system to deep sleep and I need them in non-RTOS itself .

    I have seen those examples of sleep modes where it is woken up from some GPIO interrupts or through UART interrupts.

    But I need to set the time for my system sleep , as soon as time elapses it should wake up  & do the task and once it is completed its task it need to read the current RTC and go for sleep mode for set time interval from currently read RTC!!

    How to integrate the read of RTC in sleep mode code ?

    Thank you ,

    Bindu

  • okay,I got the logic working in hibernation code with RTC!!
    But whn it gets powered on , it again restarts from the beginning , wch i dont want to...
    I want the process to be continued from whr it left before going to hibernation mode(sleep)....
    Whn the system gets powered up I dont want to reset all the pins to default and configure them again.


    Cant I use the SycCtl Deep Sleep mode with RTC??!!
    If so can I get to know what are the instruction set to use for it and how?

    Thank you!!
    Bindu :)
  • Hello Bindu,

    BINDUSHREE M V said:
    Cant I use the SycCtl Deep Sleep mode with RTC??!!

    According to the Technical Reference Manual for MSP432E4 device, this cannot be done. I have attached the screenshot of the relevant TRM section below.

    BINDUSHREE M V said:
    Whn the system gets powered up I dont want to reset all the pins to default and configure them again.

    If you want to wake up after a certain interval then Hibernation mode seems to be the only option. It is possible to structure your code such that you don't run the  initialization section if the restart is due to a wake up from Hibernation. The "hibernate" example has code that can be leveraged to not execute a section of the application if the wake up is from Hibernation.

    Hope this helps!

    Thanks,

    Sai

  • /******************************************************************************
     * MSP432E4 example code for Hibernate VDD3ON wake-up with RTC Wakeup.
     *
     * Description: The example puts the device in hibernate VDD3ON mode with wake
     * up from the RTC MATCH. The device in active state switched the LED D2 ON.
     * To put the device in hibernate the user must press the USR_SW1
     * which turns the LED D2 OFF and puts the device into hibernate state. The
     * device will automatically wakeup from Hibernate after 5 seconds. When the
     * wake from Hibernate is detected the LED D1 is switched ON. The status can
     * be cleared by pressing USR_SW2.
     *
     *                MSP432E401Y
     *             ------------------
     *         /|\|                  |
     *          | |               PJ1|<--USR_SW2
     *          --|RST            PJ0|<--USR_SW1
     *            |                  |
     *            |               PN1|-->LED D1
     *            |               PN0|-->LED D2
     *            |                  |
     *            |            WAKE_N|<--WAKE_SW4
     *            |                  |
     *            |                  |
     * Author: Amit Ashara
    *******************************************************************************/
    /* DriverLib Includes */
    #include <ti/devices/msp432e4/driverlib/driverlib.h>
    
    /* Standard Includes */
    #include <stdint.h>
    #include <stdbool.h>
    
    volatile bool setHibEntry = false;
    
    void HIBERNATE_IRQHandler(void)
    {
        uint32_t getIntStatus;
    
        /* Get the Hibernate Interrupt Status*/
        getIntStatus = MAP_HibernateIntStatus(true);
    
        /* If wakeup is due to a RTC match then set the LED D1 ON */
        if(getIntStatus == HIBERNATE_INT_RTC_MATCH_0)
        {
            MAP_HibernateIntClear(HIBERNATE_INT_RTC_MATCH_0);
    
            /* Switch the LED D1 ON */
            MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, GPIO_PIN_1);
        }
    }
    
    void GPIOJ_IRQHandler(void)
    {
        uint32_t getIntStatus;
    
        /* Get the interrupt status from the GPIO and clear the status */
        getIntStatus = MAP_GPIOIntStatus(GPIO_PORTJ_BASE, true);
    
        if((getIntStatus & GPIO_PIN_0) == GPIO_PIN_0)
        {
            MAP_GPIOIntClear(GPIO_PORTJ_BASE, getIntStatus);
    
            /* Switch the LED D2 OFF */
            MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0);
    
            setHibEntry = true;
        }
    
        if((getIntStatus & GPIO_PIN_1) == GPIO_PIN_1)
        {
            MAP_GPIOIntClear(GPIO_PORTJ_BASE, getIntStatus);
    
            /* Switch the LED D1 OFF */
            MAP_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_1, 0);
        }
    }
    
    
    int main(void)
    {
        uint32_t systemClock;
    
        /* 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_0 | GPIO_PIN_1), GPIO_PIN_0);
    
        /* Enable the clock to the GPIO Port J and wait for it to be ready */
        MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ);
        while(!(MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOJ)))
        {
        }
    
        /* Configure the GPIO PJ0-PJ1 as input with internal pull up enabled.
         * Configure the PJ0-PJ1 for a falling edge interrupt detection */
        MAP_GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, (GPIO_PIN_0 | GPIO_PIN_1));
        GPIOJ->PUR |= (GPIO_PIN_0 | GPIO_PIN_1);
        MAP_GPIOIntTypeSet(GPIO_PORTJ_BASE, (GPIO_PIN_0 | GPIO_PIN_1),
                                             GPIO_FALLING_EDGE);
        MAP_GPIOIntEnable(GPIO_PORTJ_BASE, (GPIO_INT_PIN_0 | GPIO_INT_PIN_1));
    
        MAP_IntEnable(INT_GPIOJ);
    
        /* 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);
            MAP_HibernateRTCSet(0);
            MAP_HibernateRTCEnable();
            HIB->CTL |= HIB_CTL_VDD3ON;
        }
    
        MAP_HibernateIntEnable(HIBERNATE_INT_RTC_MATCH_0);
        MAP_IntEnable(INT_HIBERNATE);
    
        /* Wait for the Hibernate entry flag to be set */
        while(!setHibEntry)
        {
        }
    
        /* Read the current RTC value and add 5 seconds to the same for
         * the wakeup interval */
        MAP_HibernateRTCMatchSet(0, (MAP_HibernateRTCGet()+5));
        MAP_HibernateRequest();
    
        while(1)
        {
        }
    }
    

    In the above example code , after hibernation wake up due to the RTC match , the program starts from beginning of the main() again .

    Whr it again starts the configuration of GPIO pins and then glow the LED(D1)  ON , thats in the hibernate interrupt handler...

    My requirement is to not to config the GPIOs or stuff and not to start from the beginning of main...

    Can you please suggest how to do that!!!

    Thank you...

    Bindu

  • Can you please attach the part of code snippet that constrain the execution of a section of application if the wake up is from hibernate...
    In that example they are only using the HibernateDataSet() instruction to store the variables in battery_back_up_memory.I couldnt found any other related solution in it..

    Thank you,,,
    Bindu
  • Hello Bindu,

    The example called "hibernate" (./examples/nortos/MSP_EXP432E401Y/driverlib/hibernate/) uses the API "HibernateIsActive" to determine if the MCU is waking up or not. You are looking at some other example.

    You could use the API HibernateIsActive to determine if the wake up is from hibernation or a system reset. The example uses other means, in conjunction with this API to isolate code that is meant for system reset.

    Thanks,
    Sai

**Attention** This is a public forum