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.

MSP430FR4133: RTC with XT1CLK source works regardless of P4SEL0 settings

Part Number: MSP430FR4133

I have an interesting problem.

I am using the MSP‑EXP430FR4133 and playing with the 32kHz crystal (connected to P4.1 and P4.2) and the RTC.

I set up the RTC in the following way:

RTCCTL = RTCSS__XT1CLK | RTCSR | RTCPS__1 | RTCIE; // XCO, reset, no divider, interrupt enable

The surprising thing is that the RTC seems to work even without setting P4SEL0 = BIT1 | BIT2. Infact, it even works with me explicitly setting P4SEL0 = 0.

According to the MSP430FR4133 datasheet (page 57) this simply shouldn't work, because the pins the XTAL is connected to will not be connected to the clock system.

Any suggestions about what's going on?

  • Hi Rob,

    Hmmm....not sure what is going on here.  Based on the documentation, this should not be happening.  I'll set this up on the bench and probe around.  Is this a show stopper for you?

  • Thank you Dennis. I've included my code from CCS below.

    This is a show-stopper for me because power usage and reliability is important in this product, and I'm not comfortable with the risk of not understanding what's happening here.

    I've set P4SEL0 in multiple places, just to be as certain as I can be that it really should be 0.

    #include <msp430.h>
    
    void init_rtc(void);
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;    // Stop the Watchdog Timer
        PM5CTL0 &= ~LOCKLPM5;
    
        P1DIR |= BIT0;   // Set P1.0 as output
    
        P4SEL0 = 0x0;
        RTCMOD = 32768;  // The RTC will overflow/interrupt when reaching 32768
        P4SEL0 = 0x0;
        RTCCTL = RTCSS__XT1CLK | RTCSR | RTCPS__1 | RTCIE; // XCO, reset, no divider, interrupt enable
        P4SEL0 = 0x0;
        __enable_interrupt();
        P4SEL0 = 0x0;
    
    }
    
    // RTC interrupt service routine
    #pragma vector=RTC_VECTOR
    __interrupt void RTC_ISR(void)
    {
        if (RTCIV == RTCIV_RTCIF)
        {
            P1OUT ^= BIT0;
        }
    }

  • Hi Rob,

    Ok, happy to help out on this.  Let me make sure I understand the goal.  You do intend to use XT1 as the clock source for RTC, correct?

  • Thanks Dennis.

    That is correct, I intend to use XT1 as the clock source. I know that I need to set P4SEL0 = BIT1 | BIT2 in order to have the XT1 clock function.

    I am concerned by the fact that the XT1 clock seems to function even when P4SEL0 = 0. In the code I shared above the LED on P1OUT blinks, even though it shouldn't.

  • Hi Rob,

    After some experimentation, it appears setting P4SEL = 0x00 and RTCCTL = RTCSS__XT1CLK | RTCSR | RTCPS__1 | RTCIE doesn't stop XT1.  But, setting P4SEL = 0x00 and RTCCTL = RTCSS__DISABLED | RTCSR | RTCPS__1 | RTCIE does.  I verified this with an oscilloscope.  So it appears that enabling the RTC enables the XT1, which is bad news if you are trying to use XT1IN and XT1OUT as P4.1 and P4.2 digital IO.  I'll need to check with the systems team to verify this.  In your case it shouldn't be an issue since you will be using those pins for XT1.

    Here is a copy of my code.

    #include <msp430.h>
    
    int main(void)
    {
        WDTCTL = WDTPW | WDTHOLD;    // Stop the Watchdog Timer
        PM5CTL0 &= ~LOCKLPM5;
        P1DIR = 0xFF;
        P1OUT = 0x00;
        P2DIR = 0xFF;
        P2OUT = 0x00;
        P3DIR = 0xFF;
        P3OUT = 0x00;
        P4DIR = 0xFF;
        P4OUT = 0x00;
        P5DIR = 0xFF;
        P5OUT = 0x00;
        P6DIR = 0xFF;
        P6OUT = 0x00;
        P7DIR = 0xFF;
        P7OUT = 0x00;
        P8DIR = 0xFF;
        P8OUT = 0x00;
    
    #if 1 // enable XT1 pins
        P4SEL0 = (BIT1 | BIT2);
        RTCCTL = RTCSS__XT1CLK | RTCSR | RTCPS__1 | RTCIE;
    #else // disable XT1 pins
        P4SEL0 = 0x00;
        RTCCTL = RTCSS__DISABLED | RTCSR | RTCPS__1 | RTCIE;
    #endif
    
        RTCMOD = 32768;  // The RTC will overflow/interrupt when reaching 32768
    
        __enable_interrupt();
    
        // enter LPM3
        LPM3;
    
        // sleep
        for(;;);
    
    }
    
    // RTC interrupt service routine
    #pragma vector=RTC_VECTOR
    __interrupt void RTC_ISR(void)
    {
        if (RTCIV == RTCIV_RTCIF)
        {
            P1OUT ^= BIT0;
        }
        LPM0_EXIT;
    }
    
    

  • Thank you very much for confirming that! I'd be interested to hear what the systems team says.

    So it appears that enabling the RTC enables the XT1

    Does enabling the RTC with RTCSS__SMCLK or RTCSS__VLOCLK also enable XT1? Or only with RTCSS__XT1CLK?

**Attention** This is a public forum