I'd like to show an alarm icon in the lcd screen of my ez430-2500 Chrono every 10 seconds.
I have created a function to initialize the Timer0_A2 and other to stop it.
I'm in Continuous mode.
The problem is I only can show this icon every 2 seconds (2 seconds off, 2 seconds on - Period=4seconds).
I don't know if the problem can be that the TA0CCR2 have to be always smaller than TA0CCR0 or FFFF (it is 32767 and the clock source is 65536).
The base code is the example code that comes with the chrono. The changes in timer.c are in bold (there is not all the code, only what I consider important to show):
void Timer0_Init(void)
{
// Set interrupt frequency to 1Hz
TA0CCR0 = 32768 - 1;
// Enable timer interrupt
TA0CCTL0 |= CCIE;
// Clear and start timer now
// Continuous mode: Count to 0xFFFF and restart from 0 again - 1sec timing will be generated by ISR
TA0CTL |= TASSEL0 + MC1 + TACLR;
}
void Timer0_A2_Start(void) //this function is called when I push DOWN button
{
// Update CCR
TA0CCR2 = 327680; // 10 seconds
// Reset IRQ flag
TA0CCTL2 &= ~CCIFG;
alarm_on=1; //variable to blink the icon
// Enable timer interrupt
TA0CCTL2 |= CCIE;
}
void Timer0_A2_Stop(void) //this function is called when I push DOWN button the second time
{
// Clear timer interrupt
TA0CCTL2 &= ~CCIE;
}
#pragma vector = TIMER0_A1_VECTOR
__interrupt void TIMER0_A1_5_ISR(void)
{
u16 value, value2;
switch (TA0IV)
{
// Timer0_A1 BlueRobin timer
case 0x02: // Timer0_A1 handler
BRRX_TimerTask_v();
break;
// Timer0_A2
case 0x04: // Timer0_A2 handler
// Disable IE
TA0CCTL2 &= ~CCIE;
// Reset IRQ flag
TA0CCTL2 &= ~CCIFG;
TA0CCR2+=327680;
// Show icon
if (alarm_on){
display_symbol(LCD_ICON_ALARM, SEG_ON);// showing the icon on the lcd screen
alarm_on=0;
}
else{
display_symbol(LCD_ICON_ALARM, SEG_OFF);// hiding the icon on the lcd screen
alarm_on=1;
}
// Enable timer interrupt
TA0CCTL2 |= CCIE;
break;
// Timer0_A4 One-time delay
case 0x08: // Disable IE
TA0CCTL4 &= ~CCIE;
// Reset IRQ flag
TA0CCTL4 &= ~CCIFG;
// Set delay over flag
sys.flag.delay_over = 1;
break;
}
// Exit from LPM3 on RETI
_BIC_SR_IRQ(LPM3_bits);
}
Please, I'd be glad if someone help me,
Thank you.