(Extra Credit) Lab 6c – Timer using Up Mode
6. Add a new function call to setup Capture and Compare Register 2 (CCR2). This should
be added to initTimers().
TIMER_A_init_________________(
TIMER_A0_BASE, // Setup Timer A0
_______________________________________, // Select the CCR2 register
TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE, // Disable int; since driving LED directly
TIMER_A_OUTPUTMODE_TOGGLE, // Toggle mode creates on/off signal
_______________________________________, // Compare value to toggle at ¼ second
);
7. Compare your previous code to that below.
What did we change? _______________________________________________________
#pragma vector=TIMER0_A1_VECTOR
__interrupt void timer0_ISR(void)
{
switch(__even_in_range( TA0IV, 14 )) {
case 0: break; // No interrupt
case 2: break; // CCR1 IFG
case 4: // CCR2 IFG
_no_operation();
break;
case 6: break; // CCR3 IFG
case 8: break; // CCR4 IFG
case 10: break; // CCR5 IFG
case 12: break; // CCR6 IFG
case 14: break; // TAR overflow
GPIO_toggleOutputOnPin( GPIO_PORT_P4, GPIO_PIN7 );
break;
default: _never_executed();
}
}
During debug, we will ask you to set a breakpoint on ‘case 4’.
Why should case 4 be skipped, and thus, the breakpoint never reached?
_________________________________________________________________________
_________________________________________________________________________
CCR2 value
calculated above
goes here
MSP430 Workshop - Timers 6 - 53