(Extra Credit) Lab 6c – Timer using Up Mode
4. Modify the TIMER_A_configureUpMode() function?
Here is the code we wrote for the previous part of the lab exercise. We only need to make
one change to the code. Since we will drive the signal directly from the timer, we don’t need
to generate the CCR0 interrupt anymore.
Mark up the code below to disable the interrupt.
(We’ll bet you can make this change without
even looking at the API documentation. Intuitive code is one of the benefits of using DriverLib!)
TIMER_A_configureUpMode(
TIMER_A0_BASE, // Setup Timer A0
TIMER_A_CLOCKSOURCE_ACLK,
// Timer clock source
TIMER_A_CLOCKSOURCE_DIVIDER_1, // Timer clock divider
0xFFFF / 2, // Period: (0x8000) / 32Khz = 1/2 sec
TIMER_A_TAIE_INTERRUPT_ENABLE, // Enable interrupt on TAR counter rollover
TIMER_A_CCIE_CCR0_INTERRUPT_ENABLE, // Enable CCR0 compare interrupt
TIMER_A_DO_CLEAR // Clear TAR & previous divider state
);
5. What ‘compare’ value does CCR2 need to equal in order to toggle the output signal at
¼ second?
¼ Second
CCR2 = __________________
½ Second
6 - 52 MSP430 Workshop - Timers