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.