TI-RTOS for TivaC
2.14.04.31
|
PWM driver implementation using Tiva General Purpose Timer peripherals.
============================================================================
The PWM header file should be included in an application as follows:
This driver configures a Tiva General Purpose Timer (GPT) in PWM mode. Creating a PWM instance will make the corresponding timer unavailable to the TI-RTOS kernel until the PWM instance is closed. Additionally, if the required timer is already used by the kernel, the PWM instance will not be opened.
When in PWM mode, each GPT is divided into 2 PWM outputs. This driver manages each output as independent PWM instances. The timer is automatically configured in count-down mode using the system clock as the source.
The period in the PWM_Params structure must be used to set the intial period. After opening, the PWM_control() API can be used to change a period. The period and duty registers are 16 bits wide; thus, prescalars are used to extend period and duty registers. The maximum period supported is calculated as: MAX_PERIOD = (((MAX_PRESCALAR + 1) * MAX_MATCH_VAL) / CYCLES_PER_US) - 1 80 MHz clock: (((255 + 1) * 65535) / 80) - 1 = 209711 microseconds 120 MHz clock: (((255 + 1) * 65535) / 120) - 1 = 139807 microseconds
Below is an example of how to use the PWM_control() to change a period:
Updates to a PWM instance will occur instantaneously (i.e. GPT peripherals do not have shadow registers). 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 | PWMTimerTiva_HWAttrs |
PWMTimerCC3200 Hardware attributes. More... | |
struct | PWMTimerTiva_Object |
PWMTimerTiva Object. More... | |
Macros | |
#define | PWMTimerTiva_CHANGE_PERIOD PWM_CMD_RESERVED + 0 |
Typedefs | |
typedef struct PWMTimerTiva_HWAttrs | PWMTimerTiva_HWAttrs |
PWMTimerCC3200 Hardware attributes. More... | |
typedef struct PWMTimerTiva_Object | PWMTimerTiva_Object |
PWMTimerTiva Object. More... | |
Variables | |
const PWM_FxnTable | PWMTimerTiva_fxnTable |
#define PWMTimerTiva_CHANGE_PERIOD PWM_CMD_RESERVED + 0 |
typedef struct PWMTimerTiva_HWAttrs PWMTimerTiva_HWAttrs |
PWMTimerCC3200 Hardware attributes.
These fields are used by driverlib APIs and therefore must be populated by driverlib macro definitions. For CCWare these definitions are found in:
A sample structure is shown below:
typedef struct PWMTimerTiva_Object PWMTimerTiva_Object |
PWMTimerTiva Object.
The application must not access any member variables of this structure!
const PWM_FxnTable PWMTimerTiva_fxnTable |