Other Parts Discussed in Thread: MSP430F5659
hello,
I am using msp430f5659 micro controller. I am interfacing internal rtc module using the example given by ti. My RTCis working correctly but sometimes it stuck in "do while" loop. I did it on different hardware units but i am facing the same problem on all hardware. I am using a crystal of 32.768KHz.
I am using a battery of 3.6v on vbat pin a capacitor of 470nf is connected to vbak pin. Why is this problem arising? please help me to find the solution of the above problem.
while(BAKCTL & LOCKBAK) // Unlock XT1 pins for operation
BAKCTL &= ~(LOCKBAK);
UCSCTL6 &= ~(XT1OFF); // XT1 On
UCSCTL6 |= XCAP_3; // Internal load cap
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
RTCCTL01 |= RTCHOLD + RTCBCD ; // BCD mode, RTC hold, enable RTC read ready interrupt
RTCYEAR = 0x2017; // Year = 0x2011
RTCMON = 0x10; // Month = 0x06 = June
RTCDAY = 0x30; // Day = 0x22 = 22nd
RTCDOW = 0x05; // Day of week = 0x05 = Friday
RTCHOUR = 0x14;
// Hour = 0x11
RTCMIN = 0x10; // Minute = 0x59
RTCSEC = 0x00; // Seconds = 0x45
RTCCTL01 &= ~(RTCHOLD); // Start RTC calendar mode