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.

CC430F5137: RTC module - calendar mode

Part Number: CC430F5137

I have a development board with CC430F5137 microcontroller and I'm trying to set up RTC module in calendar mode.

I want to switch a first LED every second with read ready interrupt and a second LED every minute with time event interrupt. 

The ACLK is already set by default to 32.760 kHz and divided providing 1 second intervals. (I tried it with other codes and it works).

The time event is already set by default to "minute changed".

The code is very simple but it doesn't work. I tried to read RTCSEC (seconds register) with debug mode but it doesn't change.

This is the code, thank you

#include "cc430x513x.h"

int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;        // Stop Watchdog Timer

    // Set up LEDs (P1.0 and P3.0)

    P1OUT &= ~BIT0;
    P1DIR |= BIT0;
    P3OUT &= ~BIT0;
    P3DIR |= BIT0;

    // Set up RTC

    RTCCTL0 |= RTCTEVIE + RTCRDYIE;                       // Enable RTC time event and read ready interrupts
    RTCCTL1 |= RTCBCD + RTCHOLD + RTCMODE;     // BCD mode, RTC hold, calendar mode

    RTCYEAR = 0x2021;    // Year = 2021
    RTCMON = 0x06;          // Month = June
    RTCDAY = 0x02;           // Day = 2
    RTCDOW = 0x03;         // Day of week = Wednesday
    RTCHOUR = 0x10;       // Hour = 10
    RTCMIN = 0x32;           // Minute = 32
    RTCSEC = 0x45;          // Seconds = 45

    RTCCTL1 &= ~RTCHOLD;      // Start RTC

    __bis_SR_register(LPM3_bits + GIE);                   // Enter LPM3 mode with interrupts enabled

}

#pragma vector = RTC_VECTOR
__interrupt void RTC_ISR(void)
{
    switch(__even_in_range(RTCIV, 16))
    {
        case 0: break;   // No interrupt pending
        case 2:              // RTC ready (RTCRDYIFG)
            P1OUT ^= BIT0;
            break;
        case 4:              // RTC interval timer (RTCTEVIFG)
            P3OUT ^= BIT0;
            break;
        case 6: break;   // RTC user alarm (RTCAIFG)
        case 8: break;   // RTC prescaler 0 (RT0PSIFG)
        case 10: break; // RTC prescaler 1 (RT1PSIFG)
        case 12: break; // Reserved
        case 14: break; // Reserved
        case 16: break; // Reserved
        default: break;
    }
}

  • I found the solution

    The correct configuration of the registers is

    RTCCTL0 |= RTCTEVIE + RTCRDYIE;
    RTCCTL1 |= RTCBCD_H + RTCHOLD_H + RTCMODE_H;

    ...

    RTCCTL1 &= ~RTCHOLD_H;

    Or (word configuration)

    RTCCTL01 |= RTCTEVIE + RTCRDYIE + RTCBCD + RTCHOLD + RTCMODE;

    ...

    RTCCTL01 &= ~RTCHOLD;