TIMER_A: Modes of Operation

The counter of Timer_A can be configured in three different modes: count-up, continuous, and up-down. For count-up mode, the Timer_A’s counter starts at 0 and then counts up to a specified load value, then reloads the counter (very similar to Timer_32’s periodic mode). Continuous mode acts similarly, but the load value is set as the highest possible value (0xFFFF). Finally, up-down mode counts up from 0 to the specified load value, and when it reaches that load value, it begins counting back down to 0 (which in turn causes the timer to count back up again, etc.).

The output can also be configured in different modes, as shown in the table below. The output modes can be broken down into three basic actions: Set, Reset, and Toggle. As the names imply, Set makes the output high, Reset makes the output low, and Toggle switches the output between high and low. For modes with only one action, the output of the Timer_A is affected by that action when the counter reaches the loaded OC value in TAxCCRn. For modes with two actions, the first action is performed when the counter reaches the OC value in TAxCCRn, and the second action is performed when the counter reaches the Timer_A’s load value in TAxCCR0.

For a deeper look on how these different modes can be utilized, check out the Timer_A section in the technical manual (chapter19). 

Example: If a Timer_A is in up-mode and if TA0CCR0 is 8,000 and TA0CCRn is 2,000 and the output mode is Set/Reset, what is the duty cycle of the generated PWM? 

We first draw the graphics of the described Timer_A counter value and GPIO output with respect to time. The below image shows this Timer_A example. In the below figure the black line shows the counter value and the orange line shows the status of the GPIO output.

Based on the above figure, it is obvious that the duty cycle is 75%.

The below figure from the user manual shows more output modes with a counter in up-mode.