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.

MSP-EXP430FR5994: Setting RTC time/date values

Part Number: MSP-EXP430FR5994

Hi,

I have a GPS receiver which stores the year, month, day, hour, min, sec into an object called date time, i want to be able to set the RTC time/day to these times, the date time seem to not be set to the values when i assign them. Is there sometime im missing in my setup.

void rtcSetup()
{
RTCCTL0_H = RTCKEY_H; // Unlock RTC
RTCCTL0_L = RTCTEVIE_L | RTCRDYIE_L; // enable RTC read ready interrupt // enable RTC time event interrupt
RTCCTL13 = RTCBCD | RTCRDY | RTCMODE; // RTC enable, BCD mode, RTC hold
RTCCTL1 &= ~(RTCRDY); // Start RTC

}

void AresManager::setRTC(RtcDateTime *dateTime)
{
RTCYEAR = dateTime->date.year; 
RTCMON = dateTime->date.month; 
RTCDAY = dateTime->date.day;
RTCHOUR = dateTime->time.hours;
RTCMIN = dateTime->time.mins;
RTCSEC = dateTime->time.secs;
}

  • > RTCCTL13 = RTCBCD | RTCRDY | RTCMODE; // RTC enable, BCD mode, RTC hold

    I'm not familiar with Ares, but the Makuna RTC (RtcDateTime) code over at Github seems to work in binary, not BCD. Try not setting that: 

    > RTCCTL13 = RTCRDY | RTCMODE; // RTC enable, RTC hold

    [Edit: For some reason E2E won't let me post the reference link. Just go to Github and search for "Makuna".]

  • Part Number: MSP-EXP430FR5994

    Hi,

    I have a GPS receiver which updates the RTC on the MSP430 every minute, I ran tests and see that the RTC clock is not running( seconds values stays at the same value till the next GPS packet updates the RTC). These are my config settings, I dont know what I am missing/wrong. Below is my configuration settings, i'm also posting where in the program my RTC time is being updated with values from the GPS. Also, do I need to RTC_C_holdClock(), before i write and read from the RTC.

     

    int main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // Stop Watchdog
    initGPIO(); // Initializes GPIO pins
    initClockTo16MHz(); // Initialize Clock
    initUART(); // Initializes UART Communication

    RTC_C_initCalendar(RTC_C_BASE, &currentTime, RTC_C_FORMAT_BCD);
    RTC_C_setCalendarEvent(RTC_C_BASE, RTC_C_CALENDAREVENT_MINUTECHANGE);
    RTC_C_enableInterrupt(RTC_C_BASE,RTC_C_CLOCK_READ_READY_INTERRUPT + RTC_C_TIME_EVENT_INTERRUPT + RTC_C_CLOCK_ALARM_INTERRUPT);
    RTC_C_startClock(RTC_C_BASE);

    __bis_SR_register(GIE); // interrupts enabled


    while (1)
    {
    coordinator.process(&currentTime); // continuously read parse buffer, once "$" is read starts storing characters in packetbuffer till "/n" character then runs NMEAParse function
    printf("%d \n", currentTime.Seconds);
    coordinator.processQueue(&currentTime);
    }
    }

    void AresManager::extractData(vector<char> data, Calendar*currentTime, int * p, int mSec)
    {
    char sday[3] = "";
    char smonth[3] = "";
    char syear[3] = "";
    char shour[3] = "";
    char smin[3] = "";
    char ssec[3] = "";
    char smsec[5] = "";

    strncpy(shour, &data[*p + 1], 2);
    int hour = atoi(shour);
    currentTime->Hours = hour;

    strncpy(smin, &data[*p + 3], 2);
    int minute = atoi(smin);
    currentTime->Minutes = minute;

    strncpy(ssec, &data[*p + 5], 2);
    int sec = atoi(ssec);
    currentTime ->Seconds = sec;


    strncpy(smsec, &data[*p + 8], 3);
    mSec = atoi(smsec);

    strncpy(sday, &data[*(p + 8) + 1], 2);
    int day = atoi(sday);
    currentTime->DayOfMonth = day;

    strncpy(smonth, &data[*(p + 8) + 3], 2);
    int month = atoi(smonth);
    currentTime->Month = month;

    strncpy(syear, &data[*(p + 8) + 5], 2);
    int year = atoi(syear);
    currentTime->Year = year;

    }

  • What value is in (e.g.) RTCSEC?

    You don't show the actual operations, but it (still) looks like you're loading binary ("hexadecimal") data into registers in BCD mode. The UG says this can result in "unpredictable behavior". [Ref User Guide (SLAU367O) "Note" at the end of Sec. 29.2.3 (e.g.)]

**Attention** This is a public forum