Hi,
I am debugging the RTC_C function of the MSP4330FR6928 MCU in my project. I need RTC_C working in the counter mode. However, whatever I do, it is locked to the Calendar mode. I intend to generate 1Hz signal using the configuration. Unfortunately, the frequency is much higher. Could anyone help me identify the issue? Thanks. Here is the code from the IAR Workbench Library samples:
void main(void)
{
WDT_A_hold(WDT_A_BASE);
//Set P1.0 LED on
GPIO_setOutputHighOnPin(
GPIO_PORT_P3,
GPIO_PIN3
);
//Set P1.0 to output direction
GPIO_setAsOutputPin(
GPIO_PORT_P3,
GPIO_PIN3
);
/*
* Disable the GPIO power-on default high-impedance mode to activate
* previously configured port settings
*/
PMM_unlockLPM5();
HWREG8(RTC_C_BASE + OFS_RTCCTL0_H) = RTCKEY_H;
//Initialize Counter Mode of RTC_A_A
/*
* Base Address of the RTC_A_A
* Use Prescaler 1 as source for counter
* Specify counter as 8 bits, which asserts an interrupt for an overflow
*/
RTC_C_initCounter(RTC_C_BASE,
RTC_C_CLOCKSELECT_RT1PS,
RTC_C_COUNTERSIZE_8BIT);
//Initialize Prescalers
/*
* Base Address of the RTC_A_A
* Specify Initialization of Prescaler 0
* Use ACLK as source to prescaler
* Divide source by 8 for this prescaler
*/
RTC_C_counterPrescaleInit(RTC_C_BASE,
RTC_C_PRESCALE_0,
RTC_C_PSCLOCKSELECT_ACLK,
RTC_C_PSDIVIDER_256);
/*
* Base Address of the RTC_A_A
* Specify Initialization of Prescaler 1
* Use Prescaler 0 as source to prescaler
* Divide source by 16 for this prescaler
*/
RTC_C_counterPrescaleInit(RTC_C_BASE,
RTC_C_PRESCALE_1,
RTC_C_PSCLOCKSELECT_RT0PS,
RTC_C_PSDIVIDER_128);
//Enable interrupt for counter overflow
RTC_C_clearInterrupt(RTC_C_BASE,
RTCTEVIFG+
RTCOFIFG+
RT0PSIFG+
RT1PSIFG
);
RTC_C_enableInterrupt(RTC_C_BASE,
RTCTEVIE+
RT0PSIE+
RT1PSIE
);
RTC_C_enableInterrupt(RTC_C_BASE,
RTCTEVIFG+
RT0PSIFG+
RTCOFIFG+
RT1PSIFG
);
//Start RTC Clock
RTC_C_startClock(RTC_C_BASE);
__bis_SR_register(GIE);
while(1);
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=RTC_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(RTC_VECTOR)))
#endif
void RTC_ISR(void)
{
switch (__even_in_range(RTCIV, 16)) {
case 0:
break; //No interrupts
case 2:
break; //RTCRDYIFG
case 4: //RTCEVIFG
break;
case 6:
break; //RTCAIFG
case 8:
break; //RT0PSIFG
case 10:
GPIO_toggleOutputOnPin(
GPIO_PORT_P3,
GPIO_PIN3);
break; //RT1PSIFG
case 12: //failure
break;
default: break;
}
}