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.

MSP430F6736: RTC_C: unable to clear RTCMODE bit in RTCCTL1

Part Number: MSP430F6736

Hi,

I want to use the RTC_C of a MS430F6736 in Counter mode. As a user of the TI DriverLib I tried to configure the RTC module via the RTC_C_initCounter() function and wrote several own functions like this one

    HWREG8(baseAddress + OFS_RTCCTL0_H) = RTCKEY_H;
    HWREG8(baseAddress + OFS_RTCCTL13_L) &= 0xDF; // (~RTCMODE);
    HWREG8(baseAddress + OFS_RTCCTL0_H) = 0x00;

What ever I do, RTCMODE bit is still set to '1'. Needless to say that the RTC module still works in Calendar mode :-(

What am I doing wrong? Or does this RTC module only supports Calendar mode?

TIA

Christoph

  • Hi Christoph,

    I'm looking into this and will try to reply back soon. 
     
    I'm going to try this on a board, but I do remember that many of the RTC bits are retained in LPM3.5 mode which means that you have to clear LOCKLPM5 before changes to them will actually take effect - you may want to try clearing LOCKLPM5 bit in the PM5CTL0 register at the top of your code just to be sure? I'm going to try this out on a board myself as well.

    Regards,
    Katie

  • Hi Christoph,

    Unfortunately I can confirm that counter mode is not implemented in the F67xx devices. I will file this against the datasheet to very explicitly add a statement in the RTC_C description for all F67xx datasheets that states that counter mode is not available on these devices to make it clearer.

    What were you trying to do with the RTC_C in counter mode? - maybe we can help you to find a way around this if needed.

    Regards,
    Katie
  • Hi Katie,

    thank you very much for this clarification. I just need a exact to the second 32-bit counter as a time stamp. Is there maybe a Calendar2Second() and/or Second2Calendar() function for the MSP430 RTC?


    Best regards
    Christoph
  • Hi Christoph,

    The calendar mode includes information down to the second. But, it sounds like you need 2^32 worth of seconds as your maximum count. Is this a hard maximum?

    If you read the RTCTIM0 and RTCTIM1 registers in Calendar mode, they are each 16 bits so 32-bits together. RTCTIM0 will give you seconds & minutes, then RTCTIM2 gives hour and day of week. However, I understand that this isn't truly 32-bits, because for example RTCMIN rolls over at 60 so it really isn't using the full 8 bits of the RTCSEC half of the RTCTIM0 register, and so on for the other registers. The true max count of calendar mode using only these RTCTIM0 (RTCSEC + RTCMIN) and RTCTIM1 (RTCHOUR + RTCDOW) registers would actually be closer to 16-bits of data because there are wasted bits in each register.

    So if you truly need 32-bits of data for seconds then you'll also need to use the RTCDATE and RTCYEAR registers to get as many bits of data as you can.

    I am unfortunately not aware of a calendarToSecond() function, but this is a good idea so I will provide it as feedback to the team that owns driverlib. I think you'll have to create your own version of this function that reads in the data from the calendar registers and arranges it to get a 32-bit # of seconds value.

    I guess my last question would be does your data have to be in a 32-bit number of seconds format, or could you use some extra bits to store the data so that you could just use the raw calendar data as your time-stamp? I can think of scenarios where you would need a specific number of bits for time-stamp (e.g. communication with another device that expects this format), but if it's something you are just logging internally, maybe it doesn't matter and you could use the raw data.

    Please let me know if there's more we can do to help.

    Regards,
    Katie
  • Hi Katie,

    thank you very much for your reply. My application needs, as you already mentioned, a real 32-bit 'seconds since epoch' counter. So I wrote my own Calendar2Seconds() and Seconds2Calendar() functions.


    Best regards
    Christoph
  • Hi Christoph,

    i happen to be in the same shoes. Would you mind sharing your code for Calendar2Seconds() function? I will totally understand if you do.

    Thanks,

    zhiyong

**Attention** This is a public forum