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.
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
Dear Greg:
I'm not sure if you've solved the problem.
I met the same thing with you.o(╯□╰)o
I've found that in the msp430fr5339.h the alarm register's minute and hour are exchanged in AIR's register. I tried to set them as IAR's order, i failed either.
So, if you've solved the problem, please give me a hand.
Thank you. O(∩_∩)O
Gregory Wells said:RTCAMIN = AE | (timer & 0x7F);
So a simple &0x7f is surely not sufficient. Except if running the RTC in counter mode.
If AE is indeed msising in the header file, then you can simply generate it with
#define AE 0x80
I guess it has been intentionally been excluded because a global system-wide define of a two-letter toekn isn't a good idea. Maybe there is an RTC_AE define or something like that.
Hello Vincent ZHOU (and others too!)
I have posted my issues at the end of the thread titled as below:
Can you all please have a look at that post and give some inputs as to what is wrong with my simple code there!
I'm trying to configure RTC_B of Exp_FR 5739 to generate alarm 4 sec later using ACLK(sourced from VLOCLK).
Just want to generate some interrupts. Exact time not important.
Thanks in advance.
Regards
Alex
**Attention** This is a public forum