TimerA

Advanced 16-bit timer with precision PWM support and capture/compare capabilities. More...

Advanced 16-bit timer with precision PWM support and capture/compare capabilities.


Module Operation


TimerA is a 16-bit timer/counter with multiple capture/compare registers. TimerA can support multiple capture/compares, PWM outputs, and interval timing. TimerA also has extensive interrupt capabilities. Interrupts may be generated from the counter on overflow conditions and from each of the capture/compare registers.

This peripheral API handles Timer A hardware peripheral.

TimerA features include:


Basic Operation Modes


TimerA can operate in 3 modes:

TimerA Interrupts may be generated on counter overflow conditions and during capture compare events.

The TimerA may also be used to generate PWM outputs. PWM outputs can be generated by initializing the compare mode with TimerA_initCompare() and the necessary parameters. The PWM may be customized by selecting a desired timer mode (continuous/up/upDown), duty cycle, output mode, timer period etc. The library also provides a simpler way to generate PWM using TimerA_generatePWM() API. However the level of customization and the kinds of PWM generated are limited in this API. Depending on how complex the PWM is and what level of customization is required, the user can use TimerA_generatePWM() or a combination of TimerA_initCompare and timer start APIs.

The TimerA API provides a set of functions for dealing with the TimerA module. Functions are provided to configure and control the timer, along with functions to modify timer/counter values, and to manage interrupt handling for the timer.

Control is also provided over interrupt sources and events. Interrupts can be generated to indicate that an event has been captured.


Programming Example


The DriverLib package contains a variety of different code examples that demonstrate the usage of the TimerA module. These code examples are accessible under the examples/ folder of the MSPWare release as well as through TI Resource Explorer if using Code Composer Studio. These code examples provide a comprehensive list of use cases as well as practical applications involving each module.

Below is a very brief code example showing how to generate a PWM signal using the TimerA DriverLib module.

Below is the configuration parameter for the TimerA PWM config API:

/* Timer_A PWM Configuration Parameter */
Timer_A_PWMConfig pwmConfig =
{
32000,
3200
};

The next snippet of code is used to actually configure the PWM signal:

/* Setting MCLK to REFO at 128Khz for LPR mode
* Setting SMCLK to 64Khz */
/* Configuring GPIO2.4 as peripheral output for PWM and P6.7 for button
* interrupt */
/* Configuring Timer_A to have a period of approximately 500ms and
* an initial duty cycle of 10% of that (3200 ticks) */
MAP_Timer_A_generatePWM(TIMER_A0_MODULE, &pwmConfig);

Copyright 2014, Texas Instruments Incorporated