TI-RTOS Drivers
tidrivers_tivac_2_16_00_08
|
PWM driver implementation for Tiva PWM perhiperals.
============================================================================
The PWM header file should be included in an application as follows:
Refer to PWM.h for a complete description of APIs & example of use.
This driver implementation uses the Pulse Width Modulator (PWM) peripherals present on Tiva devices to generate PWM signals. Each PWM peripheral instance contains 4 PWM signal generators, each controling 2 PWM outputs (8 PWM outputs total). This driver manages each PWM output individually (each output has it's own PWM handle/instance). However since a single clock prescalar is available for a peripheral and a generator is responsable for producing 2 outputs, there are some limitations in place to ensure proper operation:
Since the period and duty registers are 16 bits wide the prescalar is used to divide the input clock and allow for larger periods. The maximum period supported is calculated as: MAX_PERIOD = (MAX_PRESCALAR * MAX_MATCH_VALUE) / CYCLES_PER_US 80 MHz clock: (64 * 65535) / 80 = 52428 microseconds 120 MHz clock: (64 * 65535) / 120 = 34952 microseconds
After opening, the PWM_control() API can be used to change a PWM generator period. However, the clock prescalar is shared by all generators so the new period must be a value that can generated with the same prescaler. Also keep in mind that changing a period affects both generator outputs. The equation below can be used to determine the prescalar for a given period: The prescalar will be the following power of 2 number (2^x): prescalar = (period * CYCLES_PER_US) / MAX_MATCH_VALUE 100 microseconds = (100 * 80) / 65535 = (0.1220) = 1 10000 microseconds = (10000 * 80) / 65535 = (12.20) = 16
Below is an example of how to use the PWM_control() API to change a period:
Finally, if the duty supplied is greater than the period; the output will remain in active state.
#include <ti/drivers/PWM.h>
Go to the source code of this file.
Data Structures | |
struct | PWMTiva_HWAttrs |
PWMTiva Hardware attributes. More... | |
struct | PWMTiva_Status |
PWMTiva_Status. More... | |
struct | PWMTiva_Object |
PWMTiva Object. More... | |
Macros | |
#define | PWMTiva_CMD_CHANGE_GEN_PERIOD PWM_CMD_RESERVED + 0 |
Control command to change the PWM period. More... | |
#define | PWMTiva_CHANGE_GEN_PERIOD PWMTiva_CMD_CHANGE_GEN_PERIOD |
#define | PWMTiva_NUM_PWM_PERIPHERALS 2 |
#define | PWMTiva_NUM_PWM_GENERATORS 4 |
Typedefs | |
typedef struct PWMTiva_HWAttrs | PWMTiva_HWAttrs |
PWMTiva Hardware attributes. More... | |
typedef struct PWMTiva_Status | PWMTiva_Status |
PWMTiva_Status. More... | |
typedef struct PWMTiva_Object | PWMTiva_Object |
PWMTiva Object. More... | |
Variables | |
const PWM_FxnTable | PWMTiva_fxnTable |
#define PWMTiva_CHANGE_GEN_PERIOD PWMTiva_CMD_CHANGE_GEN_PERIOD |
#define PWMTiva_NUM_PWM_PERIPHERALS 2 |
#define PWMTiva_NUM_PWM_GENERATORS 4 |
typedef struct PWMTiva_HWAttrs PWMTiva_HWAttrs |
PWMTiva Hardware attributes.
These fields are used by driverlib APIs and therefore must be populated by driverlib macro definitions. For TivaWare these definitions are found in:
A sample structure is shown below:
typedef struct PWMTiva_Status PWMTiva_Status |
The application must not access any member variables of this structure!
typedef struct PWMTiva_Object PWMTiva_Object |
PWMTiva Object.
The application must not access any member variables of this structure!
const PWM_FxnTable PWMTiva_fxnTable |