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: RTC Configuration (to avoid setting the RTC time upon each MCU reset)

Part Number: MSP-EXP430FR5994
Other Parts Discussed in Thread: MSP430FR5994, TM4C1294NCPDT

Hi,

  I have gone through the RTC configuration example section as part of the Out-of-box demo for MSP-EXP430FR5994. In the code below, it shows how to set the RTC upon system startup. But how do I skip the RTC setting upon system startup? I mean that the RTC is holding its value (rather maintaining the clock) and upon system startup I do not want to set the time again, I just want the RTC to continue and I will fetch the time whenever necessary. I commented the blue coloured section below to see if it helps; but this results into wrong RTC time (during RTC value read). For example, the original year setting was 'Year = 0x2018' but while reading the year value after an MCU reset, the value came as 843 (decimal).

  Note that in my application, I kept the RTC running in BCD mode while the application uses binary mode for its internal calculations. For setting the clock & for retrieving the same, the driverlib BCDtoBinary & BinaryToBCD functions have been used.

-

void Init_RTC()
{
    //Setup Current Time for Calendar
    calendar.Seconds    = 0x00;
    calendar.Minutes    = 0x00;
    calendar.Hours      = 0x00;
    calendar.DayOfWeek  = 0x01;
    calendar.DayOfMonth = 0x01;
    calendar.Month      = 0x01;
    calendar.Year       = 0x2019;

    // Initialize RTC with the specified Calendar above
    RTC_C_initCalendar(RTC_C_BASE,
                       &calendar,
                       RTC_C_FORMAT_BCD);

    RTC_C_setCalendarEvent(RTC_C_BASE,
                           RTC_C_CALENDAREVENT_MINUTECHANGE
                           );

    RTC_C_clearInterrupt(RTC_C_BASE,
                         RTC_C_TIME_EVENT_INTERRUPT
                         );

    RTC_C_enableInterrupt(RTC_C_BASE,
                          RTC_C_TIME_EVENT_INTERRUPT
                          );

    //Start RTC Clock
    RTC_C_startClock(RTC_C_BASE);
}

-

Thanks

-

Regards

Soumyajit

  • Hey Soumyajit,

    There are several different conditions which can cause a "System Reset" via a BOR, POR, or PUC and they are defined in section 1.2 of the MSP430FR5994 User's Guide. Since the RTC works in LPM3.5, I assume you really want to determine if you are waking back from this LPM mode, or if the reset was caused by another source (and possibly corrupting your RTC).

    There is a good software example showing exactly this in TI Resource Explorer: msp430fr599x_lpm3-5_01.c here: dev.ti.com/.../

    Regards,
    JD
  • Hi JD,
      Thanks for the reply. Do you mean that in case of a BOR, there is a possibility that the RTC registers will get corrupted? In other MCU(s) (say TM4C1294NCPDT), there is usually a dedicated power supply MCU pin for the internal RTC. This pin may be supplied from a super capacitor or a CR2032 coin cell. Did you mean that since MSP430FR5994 is getting its internal RTC powered by the VDD & VSS pins of the MCU, any glitch on these lines may corrupt RTC registers?

    -

    Thanks

    -

    Regards

    Soumyajit

  • Hey Soumyajit,

    Technically, yes.  The functionality you described is usually referred to as battery backup and is not available on the MSP430FR5994.  So if they device loses power completely, the RTC will be corrupted.  Battery backup is available on some MSP430's, but mainly the higher power devices where the most effective way to save power is to fully shut off the MCU.     

    Now, not all BORs mean that the RTC is corrupted because a BOR can be generated in many ways, including waking from LPMx.5.  This is why we must check in software like the example I linked. 

      

    Thanks,

    JD

  • Thanks JD,
    This clarifies my query.
    -
    Regards
    Soumyajit

**Attention** This is a public forum