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.

Setting RTC calendar time using driverlib

Other Parts Discussed in Thread: MSP430F5510

It's late in the night and I must be sleeping, otherwise I would have found it.

I'm usint RTC_A on a MSP430F5510. I've been using the driverlib (rtc_a.h) for most of my RTC needs and with good success. For example, to get current time I use this function:

RTC_A_getCalendarTime(uint32_t baseAddress);

But I can't find anything like an RTC_A_***SET***CalendarTime

Is there a reason why?

I'll just write to the registers directly right now, but I definitely must be missing something...

  • Did you have a look on RTC_A_initCalendar() ?

  • Yes and I'm using it to initialize the RTC.

    As the name implies, it initializes other things. It fiddles with RTCCTL01. I'm not sure of what side effects it might bring.

    I solved the problem by just writing to RTCMIN and RTCHOUR. I was just curious why you'd write a get without a set, if the target is read/write.

    Cheers

  • It is safe to use RTC_A_initCalendar() not only for initial time/date setup, you can also call it afterwards as many times as you need to set new time or date or time+date.

    Yes it sets RTCHOLD bit before changing time/date registers values and leaves it set after exit, which is fair enough. So in order to re-start RTC again after calling RTC_A_initCalendar() you should call RTC_A_startClock().

    I believe that lack of 'setter' function for time/date in driverlib is a trade-off between library size and performance.

    Any setter can be replaced by a series of calls:

    Calendar t;

    ...

    t = RTC_A_getCalendarTime(RTC_A_BASE);

    // Change relevant t fields here, for example:

    t.Hours = 23;

    t.Minutes = 55;

    t.Seconds = 30;

    RTC_A_initCalendar(RTC_A_BASE, &t, RTC_A_FORMAT_BINARY);

    RTC_A_startClock(RTC_A_BASE);

  • By the way, if you use driverlib 1.80.00.18 or earlier, there is an error in

    File: rtc_a.c;

    Functions: RTC_A_calendarInit(), RTC_A_initCalendar();

    See http://e2e.ti.com/support/microcontrollers/msp430/f/166/p/270697/1215342.aspx#1215342

    I did not check latest driverlib which is 1.90.00.65, it may have been fixed there.

**Attention** This is a public forum