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.
Tool/software: Code Composer Studio
Dear Team ,
We are using MSP430FR5994 Launch pad to examine the RTC_C Alarm module. Please find the configuration of RTC registers below. Alarm interrupt is not occurring. only the Event interrupt is occurring at every minute. RTC time registers are updating properly. I have gone through the errata sheet also. Not mentioned anything on this.
RTCCTL0 = RTCKEY ;
RTCCTL1 |= RTCMODE + RTCSSEL_0 ;
RTCCTL3 = 0x00;
RTCAMIN = 0x00;
RTCAHOUR = 0x00;
RTCADOW = 0x00;
RTCADAY = 0x00;
RTCCTL0_L = 0x00 ;
RTCAMIN = 0x02 ; // Alarm every 2 minutes
RTCCTL0_L = RTCRDYIE + RTCAIE ; // Enable alarm interrupt
RTCCTL0_L &= ~RTCTEVIFG; // disable the event interrupt flag;
RTCCTL1 &= ~ RTCHOLD ; // Release RTC for the operation
#pragma vector=RTC_VECTOR
__interrupt void RTC_ISR()
{
if(RTCCTL0_L & RTCRDYIFG)
{
RTCCTL0_L &= ~RTCRDYIFG;
if(strRtcFlags.bWriteToRtc)
{
strRtcFlags.bWriteToRtc =0;
RTCSEC = strRtcWrite.ucSecs;
RTCMIN = strRtcWrite.ucMins;
RTCHOUR = strRtcWrite.ucHours;
RTCDAY = strRtcWrite.ucDate;
RTCMON = strRtcWrite.ucMonth;
RTCYEAR = ((unsigned int)strRtcWrite.ucYear + 2000 );
}
strRtcRead.ucSecs = strMainParam.strTime2.ucSec = RTCSEC;
strRtcRead.ucMins = strMainParam.strTime2.ucMin = RTCMIN;
strRtcRead.ucHours = strMainParam.strTime2.ucHrs = RTCHOUR;
strRtcRead.ucDate = strMainParam.strTime2.ucDate = RTCDAY;
strRtcRead.ucMonth = strMainParam.strTime2.ucMonth = RTCMON;
strRtcRead.ucYear = strMainParam.strTime2.ucYear = (unsigned char)(RTCYEAR-2000);
}
if(RTCCTL0_L & RTCAIFG)
RTCCTL0_L &= ~ RTCAIFG;
if(RTCCTL0_L & RTCTEVIFG)
RTCCTL0_L &= ~RTCTEVIFG;
}
Thanks & Regards,
Century
Dear Ryan,
Sorry i had not copied that line of code.
But i have already set that bit. Here is the edited code. I have already gone through the user guide section for RTC_C. Still only the event interrupt is occurring even though it is not enabled.
/*********** Init RTC Registers **********************************************/
RTCCTL0 = RTCKEY ; // unlock the RTC registers
RTCCTL1 |= RTCMODE + RTCSSEL_0 ; // select RTC mode and LF xtal as source
RTCCTL3 = 0x00;
RTCAMIN = 0x00;
RTCAHOUR = 0x00;
RTCADOW = 0x00;
RTCADAY = 0x00;
RTCCTL0_L = 0x00 ;
RTCAMIN = 0x02 ; // Alarm every 2 minutes
RTCAMIN |= RTCAE; // Enable the minutes alarm bit
RTCCTL0_L = RTCRDYIE + RTCAIE ; // Enable alarm interrupt
RTCCTL0_L &= ~RTCTEVIFG; // disable the event interrupt flag;
RTCCTL1 &= ~ RTCHOLD ; // Release RTC for the operation
/************************ End of Initializing RTC Registers *****************************************/
/*************** Interrupt handler for RTC_C *****************************************************/
#pragma vector=RTC_VECTOR
__interrupt void RTC_ISR()
{
if(RTCCTL0_L & RTCRDYIFG)
{
RTCCTL0_L &= ~RTCRDYIFG;
}
if(RTCCTL0_L & RTCAIFG)
RTCCTL0_L &= ~ RTCAIFG;
if(RTCCTL0_L & RTCTEVIFG)
RTCCTL0_L &= ~RTCTEVIFG;
}
/*************** End of interrupt handler *******************************/
Here is an example of an alarm interrupt occuring at every hour 2 minutes past the hour (12:02:00, 1:02:00, 2:02:00, etc.):
#include <msp430.h> int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop Watchdog Timer P1DIR |= BIT0; // Set P1.0 as output PJSEL0 = BIT4 | BIT5; // Initialize LFXT pins // Disable the GPIO power-on default high-impedance mode to activate // previously configured port settings PM5CTL0 &= ~LOCKLPM5; // Configure LFXT 32kHz crystal CSCTL0_H = CSKEY_H; // Unlock CS registers CSCTL4 &= ~LFXTOFF; // Enable LFXT do { CSCTL5 &= ~LFXTOFFG; // Clear LFXT fault flag SFRIFG1 &= ~OFIFG; } while (SFRIFG1 & OFIFG); // Test oscillator fault flag CSCTL0_H = 0; // Lock CS registers // Configure RTC_C RTCCTL0_H = RTCKEY_H; // Unlock RTC RTCCTL0_L = RTCAIE; // enable RTC alarm interrupt RTCCTL13 = RTCBCD | RTCHOLD | RTCMODE; // RTC enable, BCD mode, RTC hold RTCYEAR = 0x2017; // Year = 0x2017 RTCMON = 0x1; // Month = 0x01 = January RTCDAY = 0x18; // Day = 0x18 = 24th RTCDOW = 0x02; // Day of week = 0x02 = Tuesday RTCHOUR = 0x10; // Hour = 0x10 RTCMIN = 0x01; // Minute = 0x01 RTCSEC = 0x45; // Seconds = 0x45 RTCAMIN = 0x02 | RTCAE; // RTC Minute Alarm RTCAHOUR = 0x00; RTCADOW = 0x00; RTCADAY = 0x00; RTCCTL13 &= ~(RTCHOLD); // Start RTC __bis_SR_register(LPM3_bits | GIE); // Enter LPM3 mode w/ interrupts enabled __no_operation(); return 0; } #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=RTC_C_VECTOR __interrupt void RTC_ISR(void) #elif defined(__GNUC__) void __attribute__ ((interrupt(RTC_C_VECTOR))) RTC_ISR (void) #else #error Compiler not supported! #endif { switch(__even_in_range(RTCIV, RTCIV__RT1PSIFG)) { case RTCIV__NONE: break; // No interrupts case RTCIV__RTCOFIFG: break; // RTCOFIFG case RTCIV__RTCRDYIFG: break; // RTCRDYIFG case RTCIV__RTCTEVIFG: break; // RTCEVIFG case RTCIV__RTCAIFG: // RTCAIFG __no_operation(); // Interrupts every xx:02:00 - SET BREAKPOINT HERE break; case RTCIV__RT0PSIFG: break; // RT0PSIFG case RTCIV__RT1PSIFG: break; // RT1PSIFG default: break; } }
Regards, Ryan
**Attention** This is a public forum