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 Drift too much



Tool/software: TI-RTOS

Hi,

I've setted up RTC time:

RTC_C_initCalendar(&myTime, RTC_C_FORMAT_BINARY);


And for test I read it and print it on console every second.
After one hour I've noticed that the time drifted like 6-10s.
I suppose this behaviour on MSP432 is not normal.
 
Do I need to calibrate something? If yes how?

Time is really critical for my project.

Thank you for the help

  • Are you using TI-RTOS? If so, what version?
  • I'm using:

    Simpleling msp432 sdk 1_30_00_40

  • What do you have for a clock source?
  • /****************** RTC *******************/
    Hwi_Handle myHwi;
    Hwi_Params hwiParams;

    /* Setup RTC */
    RTC_C_initCalendar(&myTime, 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);
    }

    /* Interrupt every minute change */
    RTC_C_setCalendarEvent(RTC_C_CALENDAREVENT_MINUTECHANGE);
    RTC_C_enableInterrupt(RTC_C_TIME_EVENT_INTERRUPT);
    RTC_C_definePrescaleEvent(prescaleSelect, prescaleEventDivider)

    /* Start clock */
    RTC_C_startClock();



    /* Initialize real-time clock */
    clock_settime(CLOCK_REALTIME, &ts);

    /****************************************/

    This is my code.

    I have a wake up also in the code on every minute.

    I suppose that I'm missing setting up the clock source? I thought it was by default the 32K crystal.
  • Just making sure that you have a 32K crystal.
  • The 32K crystal is on the MSP432401R.

    Is this the correct way to set the RTC? Do I need something else to set?

    With the code above the clock source is set?

    Thank you
  • I'm stack at setting the external crystal.

    void setXT() {
        bool noerror=false;
        MAP_CS_setExternalClockSourceFrequency(32768, 48000000);
        while(noerror==false){
            noerror = MAP_CS_startLFXT(CS_LFXT_DRIVE3);
        }
        MAP_CS_initClockSignal(CS_BCLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
    }

    Unfortunately the CS_startLFXT does not return status 1.

    Is something wrong with my code?

  • Have you also configured the IO for the crystal?

    /* Configuring pins for peripheral/crystal usage and LED for output */
    MAP_GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_PJ,
    GPIO_PIN0 | GPIO_PIN1, GPIO_PRIMARY_MODULE_FUNCTION);
    MAP_GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);

    /* Setting the external clock frequency. This API is optional, but will
    * come in handy if the user ever wants to use the getMCLK/getACLK/etc
    * functions
    */
    CS_setExternalClockSourceFrequency(32000,48000000);

    /* Starting LFXT in non-bypass mode without a timeout. */
    CS_startLFXT(CS_LFXT_DRIVE3);

    Taken from : dev.ti.com/.../

    Regards,
    Chris
  • I've tried the no RTOS version and I found out that the program hangs at this line:

    /* Starting LFXT in non-bypass mode without a timeout. */
    CS_startLFXT(CS_LFXT_DRIVE3);

    If I comment out this line the program continue.

    I suppose that the example above works.

**Attention** This is a public forum