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.

RTOS: MSP432 RTC C Wake Up - policy

Tool/software: TI-RTOS

Hi,

My goal is to put my msp432 into sleep and to wake it up x hour later or by an external interrupt(I will need to switch this policies).

I have enabled the sleep policy.

const PowerMSP432_Config PowerMSP432_config = {
    .policyInitFxn = &PowerMSP432_initPolicy,
    .policyFxn = &PowerMSP432_sleepPolicy, 
    .initialPerfLevel = 2,
    .enablePolicy = true,
    .enablePerf = true
};


So the processor should go to sleep when I call Task_sleep().

But I as I see the processor dos not go to sleep.

Moreover I don't know how to enable the RTC_C to wake up later on.

The examples I found are only for MspWare.

Can you please help how can I put msp432 to sleep & wake it up on interrupt or RTC alarm with TI RTOS.

Thank you

  • Hello,

    Which version of TI-RTOS or SimpleLink SDK do you have installed?

    Derrick
  • Hello Derrick.

    My ti rtos version is:
    2.16.00.08

  • Hello,

    If upgrading to a newer version is possible, the new SimpleLink™ MSP432™SDK includes powersleep, powerdeepsleep and powershutdown examples.

    Otherwise, if you import the empty example and enable power, are you able to see the device entering low power mode?

    In your application, try utilizing the Power_getConstraintMask() API to check if anything may be preventing the device from entering a sleep state. You can read more on the Power Driver in C:/ti/tirtos_msp43x_2_16_00_08/products/tidrivers_msp43x_2_16_00_08/docs of your product.

    Derrick

  • Hello Derrick!

    I've upgraded the RTOS. As I see the sleep examples works. The bigtime example crashes :/.

    The clock also seams to work like it should with this code:

            UInt32 t;
            time_t t1;
            struct tm *ltm;
            char *curTime;
            /* set to today’s date in seconds since Jan 1, 1970 */
            Seconds_set(1412800000); /* Wed, 08 Oct 2014 20:26:40 GMT */
            t = Seconds_get();
            /*
             * Use overridden time() function to get the current time.
             * Use standard C RTS library functions with return from time().
             * Assumes Seconds_set() has been called as above
             */
            t1 = time(NULL);
            ltm = localtime(&t1);
            curTime = asctime(ltm);
            System_printf("Time(GMT): %s\n", curTime);

    Is this the correct way to set up the RTC time with SimpleLink? 

    How can I set up an RTC wake up alarm? (Directly setting RTCCTL1 register) or there is an better way?

    Thank you for your help!

  • Hello,

    Starting with the powersleep example, you can add RTC functionality using driverlib. You will notice that powersleep.c includes the following:

    #include <ti/devices/msp432p4xx/driverlib/driverlib.h>

    This includes all headers you may need. In the following steps, we will create a hardware interrupt function that services the RTC using the kernel and driverlib.

    1. APaste the following in your application before main():

    #include <ti/sysbios/hal/Hwi.h>
    
    void RTCHwiFxn(uintptr_t arg);
    
    const RTC_C_Calendar myCalendarTime = {
        .seconds        = 0,
        .minutes        = 30,
        .hours          = 10,
        .dayOfWeek      = 3,
        .dayOfmonth     = 4,
        .month          = 4,
        .year           = 2017,
    };

    2. Add the following to the beginning of *mainThread. This sets up the RTC and a interrupt service routine using the Hwi module:

        Hwi_Handle myHwi;
        Hwi_Params hwiParams;
    
        /* Setup RTC */
        RTC_C_initCalendar(&myCalendarTime, RTC_C_FORMAT_BINARY);
    
        /* Setup Hwi */
        Hwi_Params_init(&hwiParams);
        myHwi = Hwi_create(INT_RTC_C, RTCHwiFxn, &hwiParams, NULL);
    
        if (myHwi == NULL) {
            /* failed */
            while (1);
        }
    
        /* Optionally, can set Alarm condition for a particular time
        RTC_C_setCalendarAlarm(myCalendarTime.minutes + 2,
                               myCalendarTime.hours,
                               myCalendarTime.dayOfWeek,
                               myCalendarTime.dayOfmonth);
        RTC_C_enableInterrupt(RTC_C_CLOCK_ALARM_INTERRUPT);
        */
    
        /* Interrupt every minute change */
        RTC_C_setCalendarEvent(RTC_C_CALENDAREVENT_MINUTECHANGE);
        RTC_C_enableInterrupt(RTC_C_TIME_EVENT_INTERRUPT);
    
        /* Start clock */
        RTC_C_startClock();

    3.  Add the following function to your code. This will serve as the interrupt service routine for the RTC.

    void RTCHwiFxn(uintptr_t arg)
    {
        RTC_C_clearInterruptFlag(RTC_C_TIME_EVENT_INTERRUPT);
        GPIO_write(Board_GPIO_LED1, Board_GPIO_LED_ON);
    }

    4.  Add this line to the existing notifyFxn().

    GPIO_write(Board_GPIO_LED1, Board_GPIO_LED_OFF);

    Derrick

  • The only think that I can say is THANK YOU a LOT!!!

    It works perfectly!

    The SimpleLink code is really clean to understand.

    Regards

  • Hello Derrick!

    After more in deep testing I found that the RTC is not accurate in one hour there is a 10s drift from the actual time.

    As I see the 32KHz Crystal is not working. I don't know if this is connected with the low power mode or not.

    Can you please help me how can I make the RTC time stable?

    Thank you

  • This follow-up question looks like a dup of e2e.ti.com/.../2168287. I'm going to close this thread out since the MSP forum is the best place to answer the RTC drift question (and it looks like there is active communication going on).