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.
Dear All,
I have designed a PCB that has a XT1 external 32.768KHz crystal attached across XIN & XOUT.
I am trying to configure the RTC_A and to toggle P1.1 and P1.2 output every minute in software.
But RTC doesn't work. What's wrong?
Here is my code;
#include <msp430f5510.h> #pragma vector = RTC_VECTOR //RTC interrupt service __interrupt void TOG_min(void) { if(RTCTEVIFG == 1) { P1OUT ^= 0x06; } } int main(void) { WDTCTL = WDTPW | WDTHOLD; P1SEL &=~(0x06); P1DIR |= (BIT1 + BIT2); P1OUT |= 0x06; P5SEL = 0x30; P5DIR |= 0x20; RTCCTL0 |= (RTCTEVIE + RTCRDYIFG); RTCCTL1 |= (RTCBCD + RTCHOLD +RTCMODE + RTCSSEL_ACLK + RTCTEV_0); RTCYEARH = 0x20; RTCYEARL = 0x22; RTCMON = 0x12; RTCDAY = 0x05; RTCDOW = 0x00; RTCHOUR = 0x10; RTCMIN = 0x01; RTCSEC = 0x01; RTCCTL1 &= ~RTCHOLD; __bis_SR_register(LPM3_bits + GIE); while(1); }
> if(RTCTEVIFG == 1)
This test is always False since RTCTEVIFG == 4. I suspect you meant:
> if(RTCCTL0 & RTCTEVIFG)
Don't forget to clear it afterwards with "RTCCTL0 &= ~RTCTEVIFG;", or use the RTCIV register.
-----
Perhaps the simplest way to see whether the RTC is running is to wait a few seconds, pause the debugger, and see if RTCSEC/RTCMIN are different from what you set them to.
Hello Yumi,
When posting code to the forum, please utilize the code insert button for formatting menu of Insert , </> Code. I've edited your post to reflect this.
In addition to Bruce's comment, also double check your external crystal is oeprating correctly with thsi code example: https://dev.ti.com/tirex/explore/node?node=A__AAbdlkLHGBFsUC9B8poxrA__msp430ware__IOGqZri__LATEST
For additional crystal debug please see the following application note: www.ti.com/lit/slaa322
Thank you for your advice.
I modified the code as you suggested but RTC still doesn't work.
Is there any more code I need to add?
How do you tell that the RTC isn't working?
Did you try the program Jace H suggested?
I created a new code as suggested by Jace H but it didn't work.
There seems to be a problem with the test board.
I will recreated the test board and ask for help again if there are any problems.
Thank you.
**Attention** This is a public forum