Hi everyone;
I am trying to get the alarm to work properly on my msp430fr5739 but unfortunately it seems that every time the alarm is supposed to trigger, the processor just ignores it. I believe that I am setting up the registers incorrectly but I haven't been able to figure out how they need to be configured. This is the code I'm currently using
void RTC_init(void)
{
RTCCTL01 |= RTCHOLD + RTCRDYIE + RTCAIE; // hold rtc for setting; enable rtc ready interrupt; 1sec
RTCSEC = 0;
RTCMIN = 0;
RTCHOUR = 0;
RTCAMIN = 1;
RTCAHOUR = 0;
RTCCTL01 &= ~(RTCHOLD + RTCAIFG); // release rtchold, begin count
}
// clock init
void CS_init(void)
{
PJSEL0 |= BIT4 + BIT5; // XT1
CSCTL0_H = 0xA5; // Unlock register
CSCTL1 |= DCOFSEL0 + DCOFSEL1; // Set max. DCO setting
CSCTL2 = SELA_0 + SELS_3 + SELM_3; // set ACLK = XT1; MCLK = DCO
CSCTL3 = DIVA_0 + DIVS_0 + DIVM_0; // set all dividers
CSCTL4 |= XT1DRIVE_0;
CSCTL4 &= ~XT1OFF;
do
{
CSCTL5 &= ~XT1OFFG; // Clear XT1 fault flag
SFRIFG1 &= ~OFIFG;
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
CSCTL0_H = 0x01; // Lock Register
}
// RTC_b isr
#pragma vector=RTC_VECTOR
__interrupt void rtc_isr(void)
{
switch(__even_in_range(RTCIV,0x12))
{
case RTCIV_NONE: break; // No interrupt
case RTCIV_RTCRDYIFG: // rtc ready
while (!(RTCRDY));
PJOUT ^= BIT0;
sec = RTCSEC;
min = RTCMIN;
hrs = RTCHOUR;
break;
case RTCIV_RTCTEVIFG: // rtc interval timer
// do nothing here for now
break;
case RTCIV_RTCAIFG:
PJOUT ^= BIT2;
timeToSend = 1;
break; // rtc user alarm
case RTCIV_RT0PSIFG: break; // rtc prescaler 0
case RTCIV_RT1PSIFG: break; // rtc prescaler 1
case RTCIV_RTCOFIFG: break; // rtc oscillator fault
default: break;
}
}
According to the user's guide, as well as a few examples I've sen I need to use the AE (alarm enable bit) for the respective alarm registers. However, AE does not exist in the msp430fr5739.h file. Most of the set-ups that I have seen for similar micro-controllers look something like this
RTCAMIN = AE | (timer & 0x7F);
with "timer" being the value at which you want to trigger the alarm interrupt.
Does anyone know if there is an equivalent AE bit in the msp430fr5739.h file? or am I doing something else incorrectly that anyone can point out?
Please tell me what I am missing here, or any advice that you think would be helpful
Thanks
Greg