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.

MSP430F6779A: RTC_C module is initializing after main power cut..

Part Number: MSP430F6779A
Other Parts Discussed in Thread: TIDM-AUX-MODULE, MSP430F6779

hello,

i am using slaa577g lib. ref. for energy meter in which RTC is always getting initialized whenever i am switching of the main power supply. actually i am new to microcontroller and got stuck in this for past one week so i need solution for this,

i have connected backup battery to the VBAT pin, it means 32khz crystal is always running so i want solution on how to get the incremented value of the rtc after power off and on...

 i need urgent solution on it coz i am on e-meter project, if anyone is having solution plxzz reply a.s.a.p.

thanxxx...

  • Hi Sumit,

    Are you asking how to use the RTC to keep track how long the main power has been off after a power failure?

    Regards,

    James

    MSP Customer Applications
  • hi James,

    thanx for replying me soon..,

    yea, same but slightly different i want my date and time to be updated after power on which is not happening.

    this is the schematic of my rtc section....

    thanxx..

  • Shcematic of rtc section..

    thanxxx..

  • hello James,
    for past two days i m waiting for your reply, i had answered to your question and had attached schematic of my RTC section too, plz review it and provide solution for it..

    regards,
    Sumit
  • If I'm understanding you correctly, you want to measure the time between a power loss and when the power turns back on.

    Thus, you could either use the RTC_C module to get triggered when there's a power loss and halt the RTC when power turns back on. The counts would be the number of seconds when power was off.

    An alternative method could be to use the calendar mode with two external events enabled (one for power loss, another for when power turns back on). The pins RTCCAP0 and RTCCAP1 can be used as an event or tamper detection input of an external switch (mechanical or electronic). After device power-up, this feature can be enabled by setting the TCEN bit in the RTCTCCTL0 register. Event and tamper detection with time stamp is supported in all MSP430 operating modes, as long as there is a valid RTC power supply. When there is an event on RTCCAPx pin and the time capture feature is enabled (TCEN = 1), the corresponding CAPEV bit in RTCCAPxCTL register is set and the corresponding time stamp information (seconds, minutes, hours, day of month, month and year) is stored in the respective backup registers (RTCSECBAKx, RTCMINBAKx, RTCHOURBAKx, RTCDAYBAKx, RTCMONBAKx and RTCYEARBAKx). For more details about this mode, refer to Section 24.3.2 in the MSP430x5xx/x6xx User's Guide.

    Regards,

    James

    MSP Customer Applications

  • hi james,
    thanxx for providing support to me, and of course you have understand me correctly. now i m going to implement the solution provided by you then i will update the result to you..
    thanx alot....
    regards,
    Sumit
  • Hi Sumit,

    Another reference that I forgot to mention is the TIDM-AUX-MODULE TI Design. Besides highlighting how to use the auxiliary power modules and the RTC module, this design features code examples that highlight external events that trigger time captures. These should be very helpful getting you started. I'd recommend looking at the following examples discussed on pages 14 to 15 in the Battery Management and Auxiliary Power Supply Options for e-Meters Design Guide.

    • MSP430F6779_AUX_14.c
    • MSP430F6779_AUX_15.c
    • MSP430F6779_AUX_16.c

    Regards,

    James

    MSP Customer Applications

  • hi james,

    sorry for the very late reply ,

    just please check this code snippet ,where i m going wrong and  plss solve the issue...i m not getting

    #if defined(RTC_SUPPORT)
          if (!check_rtc_sumcheck())
          {
            
            rtc.year   = 0x11;
            rtc.month  = 0x03;
            rtc.day    = 0x1C;
            rtc.hour   = 0x02;
            rtc.minute = 0x03;
            rtc.second = 0x04;
            set_rtc_sumcheck();
        #if defined(__MSP430_HAS_RTC_C__) || defined(__MSP430_HAS_RTC_CE__)
           
              RTCCTL0_H = RTCKEY_H;                  // Unlock RTC
            if (RTCCTL0 & RTCOFIFG){  // init if RTCOFIFG is set
              RTCCTL13 = RTCBCD+RTCHOLD+RTCMODE+RTCTEV_0; // Init RTC
              RTCCTL0_L &= ~RTCOFIFG_L;                                                    //RTCCTL0_L &= ~RTCOFIFG_L;   // Clear Flag
              RTCSEC  = rtc.second;
              RTCMIN  = rtc.minute;                 //rtc.minute = RTCMIN;
              RTCHOUR = rtc.hour;                   //rtc.hour = RTCHOUR;
            //    RTCDOW   = rtc.DayOfWeek;
              RTCDAY   = rtc.day;
              RTCMON   = rtc.month;
              RTCYEAR  = rtc.year + 0x2000;
              RTCCTL13 &= ~RTCHOLD;                   // Enable RTC
            }
           else
            {
              RTCCTL3 |= RTCLOCK;
              RTCCTL13 = RTCBCD+RTCMODE+RTCTEV_0; // Init RTC
            }
            RTCCTL0_H = 0;   // LOCK RTC
        #endif
        }
        #endif

    please kindly help me......

    thnx and regards,

    sumit

  • hi james,

    i have posted the code snippet which i got in slaa577g lib. in this check_rtc_sumcheck() function always returning zero, and it is given that if this function will return zero then rtc will not get updated...

    i m not getting why this function is always returning zero value..

    here is that fun:

    int check_rtc_sumcheck(void)
    {
        return rtc.sumcheck == ((~(rtc.second + rtc.minute + rtc.hour + rtc.day + rtc.month + rtc.year)) & 0xFF);
    }

    please go through it and plzz help me to resolve this issue..

    waiting for help..

    thanxx

    sumit

  • Hi James,

    sorry for again for late reply i want to let you know that i have successfully completed my project and now my RTC is working very fine...

    i have set the RTCLOCK bit in RTCCTL3 which allows to keep all LPM3.5
    retention logic from write and reset operations.... thanx for your very great support thanks alot.....

    regards,

    Sumit

  • That's great! Thanks for following-up. It may help others in the community if they face a similar issue.

    Regards,

    James

    MSP Customer Applications

**Attention** This is a public forum