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.

MSP430F6636 RTC problem

Other Parts Discussed in Thread: MSP430F6636, MSP430F5659

hi,

 I am using internal RTC of MSP430F6636 micro controller in calender mode.

 My code for writing and reading RTC is given below

  RTCCTL01 |=  RTCHOLD + RTCMODE;
 
  RTCDAY  = ucGbl_WrDate;                        // Write date
  RTCMON  = ucGbl_WrMonth;                    // Write month
  RTCYEAR = ucGbl_WrYear;                      // Write year
 
  RTCHOUR = ucGbl_WrHr;                       // Write hour
  RTCMIN  = ucGbl_WrMin;                        // Write minute
  RTCSEC  = ucGbl_WrSec;                      // Write second
 
 
  RTCCTL01 &= ~(RTCHOLD);                 

  After  this i am reading RTC using following code

  while(!( RTCCTL01 & RTCRDY ));             // Wait for RTC to be ready for read

  ucGbl_RdHr    = RTCHOUR;                    // Read hout
  ucGbl_RdMin   = RTCMIN;                     // Read minute
  ucGbl_RdSec   = RTCSEC;                     // Read second
 
  ucGbl_RdDate  = RTCDAY;                     // Read date
  ucGbl_RdMonth = RTCMON;                     // Read month
  ucGbl_RdYear  = RTCYEAR;                    // Read year

  I have found that some times RTCRDY bit is not getting high.

  so code gets stuck in while loop.

  What can be reason for that ?

  • There is no way to stuck in while loop. Are you sure that code stop there?

    According to the User Manual, RTCRDY bit should stay cleared for 128/32768 sec (3.9ms) and should be set for whole rest of second.

    I found TI suggestion and implementation of RTCRDY bit is not clever. If you are not using Second Change interrupt  (RTCRDYIFG), I would write some code like that:

    {

       RTCRDYIFG = 0; // be sure flag is zero

       Read all RTC registers here

    } while(RTCRDYIFG == 1); // while reading, if second changed, simply read again

    If you are using RTCRDYIFG interrupt, you have to simulate RTCRDYIFG flag by defining another volatile bit, and set it yourself in interrupt routine.

  • I am using an MSP430F5659 with an RTC_B.  I'm also using the latest driverlib.

    I am getting the same behavior as Smitesh Mali above.

    In the driverlib function 'RTC_B_getCalendarTime()" is the line:

    while ( !(HWREG16(baseAddress + OFS_RTCCTL01) & RTCRDY) ) ;

    My code hangs there indefinitely.

    I wrote this code for a debug panel.  I press 'T' to set an initial time, and then I press 't' any time I want to read the rtc calendar:

    ---------------------------------

    case 'T':   //Set time
    {
        Calendar mytime;

        AresLogger(eDEBUG, ">T - Setting Time.\n\r");
        mytime.Seconds = 0;
        mytime.Minutes = 0;
        mytime.Hours = 0;
        mytime.DayOfMonth = 1;
        mytime.Month = 1;
        mytime.Year = 2013;

        RTC_B_calendarInit(__MSP430_BASEADDRESS_RTC_B__, mytime, RTC_B_FORMAT_BINARY);
        RTC_B_startClock(__MSP430_BASEADDRESS_RTC_B__);

    }
        break;
    case 't':
    {
        Calendar mytime = RTC_B_getCalendarTime(__MSP430_BASEADDRESS_RTC_B__);
        AresLogger(eDEBUG, "Hours=%d, Min=%d, Sec=%d\n\r", mytime.Hours, mytime.Minutes, mytime.Seconds);

    }
        break;
    ----------------------------

    Can anybody see what I'm doing wrong?

  • Are you sure that your low power 32Khz crystal functional at time time?

  • I'm using REF0 as osc source for ACLK.

    UPDATE:

    I see your point now.  RTC_B is only sourced from XLT1_OSC.  Thanks.

**Attention** This is a public forum