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.

Configuring RTC_C for MSP430F

Other Parts Discussed in Thread: MSP430F6776

Hi All,

I have designed a PCB that has a XT1 external 32.768KHz crystal attached across XIN & XOUT with two 12pF caps.

I am trying to configure the RTC_C in software and I am struggling to write to the RTCSEC...RTCYEAR registers. When I step through them they don't get written, just stay at 0x00.

Here is my small configuration code;

RTCCTL0 |= RTCKEY;         //Password protection write 0xA5 (RTCKEY) to unlock 




RTCCTL1 |= RTCBCD + RTCHOLD + RTCMODE;   //Sets Hex mode, halts RTC, Calendar Mode 




  RTCSEC = 0x02;              

  RTCMIN = 0x1F; 

  RTCHOUR = 0x0D; 

  RTCDOW = 0x02; 

  RTCDAY = 0x1B; 

  RTCMON = 0x01; 

  RTCYEAR = 0x7E0; 

   

  RTCCTL1 &= ~RTCHOLD;       //starts RTC

Any help would be appreciated.

  • Hi Jack,

    RTC_C's registers are set up a bit differently from RTC_A or RTC_B, in this case RTCCTL0 is 2 bytes wide instead of the typical 1 byte and is therefore split up into RTCCTL0_L and RTCCTL0_H. RTCCTL0_H controls the RTCKEY bit and RTCCTL0_L controls the RTC IE and IFG bits. By using RTCCTL0 you are incorrectly setting RTCCTL0_L instead of RTCCTL0_H and therefore never unlocking the RTC_C module with the key. Replace RTCCTL0 with RTCCTL0_H to fix your issue.

    Regards,
    Ryan
  • Hi Ryan,

    Changed to RTCCTL0_H = RTCKEY; with no luck.

    I haven't set any timers or anything and I am using the MSP430F6776 so don't have to set any ports for the XTAL, but I thought that wouldn't effect writing to the RTCSEC register etc.

    Jack
  • Hello Jack,

    I would set up the XTAL regardless just to make sure.  Run the following example code to ensure proper device operation and then integrate it into your application accordingly:

    MSP430F677x_RTC_01.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_EX
    * Copyright (c) 2012, 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.
    *
    *******************************************************************************
    *
    *
    * MSP430 CODE EXAMPLE DISCLAIMER
    *
    * MSP430 code examples are self-contained low-level programs that typically
    * demonstrate a single peripheral function or device feature in a highly
    * concise manner. For this the code may rely on the device's power-on default
    * register values and settings such as the clock configuration and care must
    * be taken when combining code from several examples to avoid potential side
    * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
    * for an API functional library-approach to peripheral configuration.
    *
    * --/COPYRIGHT--*/
    //******************************************************************************
    // MSP430F67791 Demo - RTC_C, Calendar Mode with Time Event and Alarm Interrupts
    //
    // Description: This program demonstrates the RTC_C mode by triggering an
    // interrupt every second and minute. This code toggles P1.0 every second.
    // This code recommends an external LFXT1 crystal for RTC accuracy.
    // ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz
    //
    // MSP430F67791
    // -----------------
    // /|\ | XIN|-
    // | | | 32kHz
    // ---|RST XOUT|-
    // | |
    // | P1.0 |--> Toggles every second
    // | |
    //
    // C. Fu
    // Texas Instruments Inc.
    // October 2012
    // Built with CCS Version: 5.1.0 and IAR Embedded Workbench Version: 5.51
    //******************************************************************************
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    MSP430F677x_RTC_02.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_EX
    * Copyright (c) 2012, 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.
    *
    *******************************************************************************
    *
    *
    * MSP430 CODE EXAMPLE DISCLAIMER
    *
    * MSP430 code examples are self-contained low-level programs that typically
    * demonstrate a single peripheral function or device feature in a highly
    * concise manner. For this the code may rely on the device's power-on default
    * register values and settings such as the clock configuration and care must
    * be taken when combining code from several examples to avoid potential side
    * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
    * for an API functional library-approach to peripheral configuration.
    *
    * --/COPYRIGHT--*/
    //******************************************************************************
    // MSP430F67791 Demo - RTC_C, LPM3.5, & alarm
    //
    // Description: The RTC_C module is used to set the time, start RTC operation,
    // and read the time from the respective RTC registers. Software will set the
    // original time to 11:59:45 am on Friday October 7, 2011. Then the RTC will
    // be activated through software, and an alarm will be created for the next
    // minute (12:00:00 pm). The device will then enter LPM3.5 awaiting
    // the event interrupt. Upon being woken up by the event, the LED on the board
    // will be set.
    //
    // NOTE: To ensure that LPM3.5 is entered properly, you would need to use an
    // external power supply.
    //
    // //* An external watch crystal on XIN XOUT is required for ACLK *//
    // ACLK = 32.768kHz, MCLK = SMCLK = default DCO~1MHz
    //
    // MSP430F67791
    // -----------------
    // /|\| XIN|-
    // | | | 32kHz
    // --|RST XOUT|-
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Regards, Ryan

  • Tried the code and all works well!

    I think it was because I hadn't implemented the AUXVCC3 charging and I had also missed the load cap configuration.

    Cheers Ryan.

**Attention** This is a public forum