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.

MSP430F5659: Problem using RTC_B without XT2 running

Part Number: MSP430F5659


Hello, 

I have a project using the RTC_B of the MSP430F5659.  The processor runs via the DCO. The XT2 crystal is intended for USB operation only to save energy. XT1 is connected to a watch crystal

The RTC_B provides a clock. The time is output in the menu. The RTCRDYIFG flag triggers an interrupt which wakes up the processor and updates the time again. When a key is pressed, the menu is also redrawn and thus the time is also output. 

If I initialize UCS as follows the whole thing works fine:

    while (BAKCTL & LOCKBAK)                 // Unlock XT1 pins for operation
        BAKCTL &= ~(LOCKBAK);
    UCSCTL6 |= XCAP_3;  					 // Lastkapazität auf ca. 12 pF gesetzt
    UCSCTL6 &= ~(XT1OFF);       			 // Set XT1 & XT2 On
    do										 // Loop until XT1,XT2 & DCO stabilizes
    {
        UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + XT1HFOFFG + DCOFFG);		// Clear XT2,XT1,DCO fault flags
        SFRIFG1 &= ~OFIFG;                  // Clear fault flags
    }
    while (SFRIFG1 & OFIFG);                // Test oscillator fault flag (OSC Fault Flag set again?)
    UCSCTL6 |= XT1DRIVE_3;					// drive strenth max
    UCSCTL6 &= ~XT2OFF;                     // Turn on XT2
    UCSCTL4 |= SELA__XT1CLK;				// Set XT1CLK as ACLK clock source --> RTC
    UCSCTL5 |= DIVA__1;						// Set ALCK source divider to 1

but of course the XT2 is running. However, if I change the two UCSCTL6 lines after the while loop to:

 UCSCTL6 |= XT1DRIVE_3 + XT2OFF;					//switch off XT2
//    UCSCTL6 &= ~XT2OFF;                   

the XT2 is turned off now and I get a strange behavior from the RTC_B. 

The periodic redraw after the RTCRDYIFG interrupt still works. The time is updated. However, when I press the key, I cannot read time from the registers RTCSEC, RTCMIN and RTCHOUR. I only read 0x00 and even after a write attempt I still read 0x00. However, reading after the interrupt still works.

The function, which generates the time-string is the same. 

Does anyone have any ideas? I don't see a XT2 function for RTC_B in the data sheet. 

Regards 

Stefan

  • It looks like

        while (BAKCTL & LOCKBAK)                   // Unlock XT1 pins for operation
               BAKCTL &= ~(LOCKBAK);
    

    is the solution of the problem. Reseting the flag solves the problem. The lines were in the ISR of RTC_B and were accordingly not executed when the key was pressed.

    I have now added clearing the flag to each run and it works.

    Stefan

**Attention** This is a public forum