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: RTC Update during power off

Part Number: MSP430F5659

Hi Team,

I'm using MSP430F5659 in my product, I'm getting updated date and time while main power is available(Coin cell battery also connected to VBat) there is no issue.

But whenever i turned off main power that time i'm not getting updated date and time. I'm getting before main power off time and date.

Below are the settings for RTC-B

void Initialize_RTC_B(void)
{
          /  / Unlock battery backup system
         while(BattBak_unlockBackupSubSystem(BAK_BATT_BASE));

// Initializes the LFXT1 crystal oscillator in low frequency mode
UCS_turnOnLFXT1(UCS_XT1_DRIVE_3,UCS_XCAP_3);

/* 1-0 RTCTEVx RW 0h Real-time clock time interrupt event
00b = Minute changed
01b = Hour changed
10b = Every day at midnight (00:00)
11b = Every day at noon (12:00) */

//Specify an interrupt to assert every minute
RTC_B_setCalendarEvent(RTC_B_BASE,
RTC_B_CALENDAREVENT_MINUTECHANGE);

//Enable interrupt for RTC Ready Status, which asserts when the RTC
//Calendar registers are ready to read.
//Also, enable interrupts for the Calendar alarm and Calendar event.
RTC_B_clearInterrupt(RTC_B_BASE,
RTCRDYIFG + RTCTEVIFG + RTCAIFG);
RTC_B_enableInterrupt(RTC_B_BASE,
RTCRDYIE + RTCTEVIE + RTCAIE);

//Start RTC Clock
RTC_B_startClock(RTC_B_BASE);
// interrupts enabled
__bis_SR_register(GIE);
__no_operation();

}   

//******************************************************************************
//
//This is the RTC_B interrupt vector service routine.
//
//******************************************************************************
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=RTC_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(RTC_VECTOR)))
#endif
void RTC_B_ISR(void)
{
// Unlock backup system
while(BattBak_unlockBackupSubSystem(BAK_BATT_BASE));

switch(__even_in_range(RTCIV,16))
{
case 0: break; //No interrupts
case 2: //RTCRDYIFG
break;
case 4: //RTCEVIFG
//Interrupts every minute
__no_operation();

//Read out New Time a Minute Later BREAKPOINT HERE
RTC_B_getCalendarTime(RTC_B_BASE);
break;
case 6: //RTCAIFG
//Interrupts 5:00pm on 5th day of week
__no_operation();
break;
case 8: break; //RT0PSIFG
case 10: break; //RT1PSIFG
case 12: break; //Reserved
case 14: break; //Reserved
case 16: break; //Reserved
default: break;
}
}

Did I miss something? 

  • Hi Krishna,

    Please find the description on Device User's Guide section 3.2 Battery Backup Operation:

  • Hi Wei,

    I found one example code on forums it was working fine with my custom hardware.

    I used the same RTC initialization settings to my project i'm getting Faulty Oscillator and Frequency down bits set. 

    If i commented the configureHardware(); ( line number 170) in RTC_Issue file (please refer attached file). I'm able to retained the RTC date and time.

    If i uncommented the line number 170(configureHardware();), Unable to get the updated date and time.

    Note:-

    1) Increased controller frequency upto 20MHz please refer SYSINIT_Init_Micro();

    2) As per 20MHz SMCLK we are implemented remaining peripherals like timers, spi, i2c and uart

    RTC_Issue.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    /* --COPYRIGHT--,BSD
    * Copyright (c) 2015, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    * --/COPYRIGHT--*/
    /**********************************************************************
    *
    * RTC_B_with_Backup.c
    *
    * This program demonstrates proper usage of RTC_B with Battery Backup on
    * F66xx family devices. The code distinguishes between a BOR event, and
    * a VBAT switching event, to determine if the RTC calendar registers
    * should contain accurate time information and initialize the RTC
    * accordingly.
    *
    * Time information is relayed to the Demo_Host F5529 Launchpad over UART
    * to be passed back to the PC and viewed by the user. This shows that
    * time is retained if VBAT is present, and is lost if VBAT becomes
    * drained.
    *
    **********************************************************************/
    #include "driverlib.h"
    #include "UART1.h"
    #include "hardwareConfig.h"
    volatile Calendar newTime;
    Calendar currentTime;
    #define UCS_MCLK_DESIRED_FREQUENCY_IN_KHZ 20000
    #define UCS_MCLK_FLLREF_RATIO 610
    #define TB0_FREQ 20000000L // SMCLK
    #define TB0_CLOCK ((float)CTRL_OPERATING_FREQ / 7) // for 1mse
    #define TB0_RELOAD(T) (unsigned int)(((float)T/1000) * TB0_CLOCK)
    #define TIMER_B0_VALUE 1 // milliseconds
    #define TIMER_B0_RELOAD TB0_RELOAD(TIMER_B0_VALUE)
    #define TA0_FREQ 20000000L // SMCLK
    #define TA0_CLOCK ((float)CTRL_OPERATING_FREQ / 7) // via TA0EX0 = 6;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Team, Any update on above query. 

  • As per my understanding, RTC can be updated during power off, using battery. With an example source code available in internet, i could able to test it. But when i integrate it to my application, its not working as expected. The extra work i have done in my code is more about  Increased controller frequency upto 20MHz. Will it have any impact? 

  • Hi,

    I don't think it is related to the controller frequency.

    If you are supply by battery to RTC, you can't access to the time and date information as described on the document.

**Attention** This is a public forum