Timer Details: Configuring TIMER_A
Compare Code Example
Let’s look at the code required to setup CCR2 for use in a Compare operation.
One thing you might notice about the TIMER_A_initCompare() function is that it requires fewer
parameters than the complementary initCompare function.
Example’s Parameter Value What is Parameter For? Value
TIMER_A0_BASE
Which timer are you using? TA0
TIMER_A_CAPTURECOMPARE_REGISTER_2
Which CCR is being configured? CCR2
TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE
Enable the CCR interrupt? CC2IE = 1
TIMER_A_OUTPUTMODE_SET_RESET
How should the output signal be handled? OUTMOD=0x3
0xBEEF
What ‘compare’ value will be written to CCR2? CCR2 = 0xBEEF
The OutputMode setting will be configured using the “Set/Reset” mode (which correlates to the
value 0x3). Once again, with so many different output mode choices, we’ll defer the full
explanation of this until the next topic.
6 - 22 MSP430 Workshop - Timers