TIMER_A: Basics
At its core, Timer_A is a timer just like Timer32. Both timers are operated by using a counter that decrements or increments every clock cycle. They are also both driven by the system clock (most of the time), whose frequency can be reduced with prescalers. However, there are two key differences between the two timers: on the MSP432, Timer_A is a 16-bit timer (compared to Timer32 which is 32 bits), and Timer_A has input capture/output compare registers. The latter attribute will be crucial to implementing a hardware-drivern PWM.
Timer_A has a unique register that can be configured in two different modes: input capture and output compare. Input capture (IC) can retrieve the current value of the Timer_A counter. This copying is tied to pre-determined changes in a GPIO pin associated with the timer. For example, we can get the exact moment a button is pressed using mechanism.
In Output compare (OC) the status of the GPIO pin associated with the Timer_A is changed based on the value of the counter. The extra register on Timer_A holds a user-chosen value. When the counter reaches the value stored in extra register, the status of a GPIO pin hanges according to a pre-defined behaviour. This mode is especially used for creating PWM.
The diagrams for IC and OC can be combined as such:
Though in actuality, they’re just a single register that can be configured in either mode.
Each Timer_A peripheral has multiple IC/OC channels. Thus, you can operate several GPIOs using only one Timer_A. Since there are more than one Timer_A peripherals, each with its own IC/OC channels, you can utilize Timer_A for various tasks simultaneously without running out of timers to use.
In Timer_A terminology, the load value is stored in a register called TAxCCR0. The other registers are called TAxCCR1, TAxCCR2, etc. In the user manual, these registers are identified as TAxCCRn.