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.

rtc in msp430

Other Parts Discussed in Thread: MSP430WARE

Hello,

   I want to use and implement  rtc in my application.  Before that, i want to make sure that it is working. So i done a simple coding only to write and read the rtc values. The code is 




//******************************************************************************
#include "driverlib.h"
#include "Timer_delay.h"
#inlude "uart.h"

volatile Calendar newTime;

void main(void)
{
Calendar currentTime;

WDT_A_hold(WDT_A_BASE);

//Set P1.0 to output direction
GPIO_setAsOutputPin(
GPIO_PORT_P1,
GPIO_PIN0
);
init_timer();
init_uart();

/*
* Select Port J
* Set Pin 4, 5 to input Primary Module Function, LFXT.
*/
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_PJ,
GPIO_PIN4 + GPIO_PIN5,
GPIO_PRIMARY_MODULE_FUNCTION
);

/*
* Disable the GPIO power-on default high-impedance mode to activate
* previously configured port settings
*/
PMM_unlockLPM5();

//Initialize LFXT1
CS_LFXTStart(
CS_LFXT_DRIVE3
);

//Setup Current Time for Calendar
currentTime.Seconds = 0x00;
currentTime.Minutes = 0x40;
currentTime.Hours = 0x06;
currentTime.DayOfWeek = 0x01;
currentTime.DayOfMonth = 0x19;
currentTime.Month = 0x10;
currentTime.Year = 0x2014;

//Initialize Calendar Mode of RTC
/*
* Base Address of the RTC_B
* Pass in current time, intialized above
* Use BCD as Calendar Register Format
*/
RTC_B_calendarInit(RTC_B_BASE,
currentTime,
RTC_B_FORMAT_BCD);


RTC_B_startClock(RTC_B_BASE);

while(1)
{
delay(60);
newTime = RTC_B_getCalendarTime(RTC_B_BASE)
delay(60);
}

}

rtc is setting properly, but when i tried to get it. Rtc is not working. 

Case 1:

   When i comment  newTime = RTC_B_getCalendarTime(RTC_B_BASE) and pause the ccs, rtc running and giving proper value. 

Case 2:

   When i include newTime = RTC_B_getCalendarTime(RTC_B_BASE) and put a break point in dealy(60). I have seen in the register of rtc(using CCS), it result is erratic. 

Is some thing i  missed to read the rtc?. I used same same API RTC_B_getCalendarTime, which is in the driverlib. So can any one guide me to fix this.

  • I am expecting response from ti

  • Did i asked very Complicated question? I request to guide me in this

  • Pinky:

    You may want to compare your code to the TI example found in MSP430ware:

    c:\ti\msp430\msp430ware_1_95_00_32\examples\devices\fr5xx\MSP430FR596x_MSP430FR595x_MSP430FR594x...Code_Examples\C\msp430fr59xx_rtc_02.c

     

  • Thanks Todd,

                   But i am having msp430ware_1_90_00. I am couldn't able to find the file name which you have mentioned above. But in the MSP430 ware i found a file name rtcb_ex1_calendermode.c . I used the same code. I don't have problem with Setting the clock and starting it. I faced a problem whenever i tried to read the clock. So can you tell where i am wrong.

  • Pinky:

    I am working with F5529, which is not exactly the same RTC as you have. If I halt the emulator, the RTC also halts. So, to get a realistic view of just what the RTC registers were doing, I would set them up initially (on TI test code) to a "future time," then wait for the clock, and would start emulation as the second reached the time I had set up. At some later point in time, I would then have my clock ready when I halted emulation, and that is how I checked to see if my time was "in sync."

    There are probably better ways to do this, but I have not yet created a CCS app that sets and reads time. I was hoping to do that with the CCS "GUI composer" but I have not had outside time to attempt...

**Attention** This is a public forum