TI-RTOS Drivers
tidrivers_msp43x_2_16_01_13
|
PWM driver implementation.
============================================================================
The PWM header file should be included in an application as follows:
This driver configures an MSP432 Timer_A peripheral for PWM. Opening a PWM instance will make the corresponding timer unavailable to the TI-RTOS kernel until all PWM instances dependant on that timer are closed. Additionally, if the required timer is already used by the kernel, PWM instances will not be opened.
When used for PWM generation, each Timer_A can produce up to 6 PWM outputs. This driver manages each output as an independent PWM instance. However since a single period and prescalar are used for all Timer outputs, there are limitations in place to ensure proper operation:
The timer is automatically configured in count-up mode using the SMCLK clock as the source. In PWM mode, the timers capture/compare register 0 is used as the period register and cannot be used to generate a PWM output.
The period and duty registers are 16 bits wide, thus a 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 12 MHz clock: (64 * 65535) / 12 = 349520 microseconds 6 MHz clock: (64 * 65535) / 6 = 699040 microseconds 3 MHz clock: (64 * 65535) / 3 = 1398080 microseconds
After opening, the PWM_control() API can be used to change the PWM period. Keep in mind the period is shared by all other PWMs on the timer. Below is an example of how to use the PWM_control() API to change a period:
Updates to a PWM instance will occur instantaneously. 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 | PWMTimerMSP432_HWAttrs |
PWMTimerMSP432 Hardware attributes. More... | |
struct | PWMTimerMSP432_Status |
PWMTimerMSP432_Status. More... | |
struct | PWMTimerMSP432_Object |
PWMTimerMSP432 Object. More... | |
Macros | |
#define | PWMTimerMSP432_CMD_CHANGE_PERIOD PWM_CMD_RESERVED + 0 |
Control command to change the PWM period. More... | |
#define | PWMTimerMSP432_CHANGE_PERIOD PWMTimerMSP432_CMD_CHANGE_PERIOD |
#define | PWMTimerMSP432_NUM_TIMERS 4 |
Typedefs | |
typedef struct PWMTimerMSP432_HWAttrs | PWMTimerMSP432_HWAttrs |
PWMTimerMSP432 Hardware attributes. More... | |
typedef struct PWMTimerMSP432_Status | PWMTimerMSP432_Status |
PWMTimerMSP432_Status. More... | |
typedef struct PWMTimerMSP432_Object | PWMTimerMSP432_Object |
PWMTimerMSP432 Object. More... | |
Variables | |
const PWM_FxnTable | PWMTimerMSP432_fxnTable |
#define PWMTimerMSP432_CHANGE_PERIOD PWMTimerMSP432_CMD_CHANGE_PERIOD |
#define PWMTimerMSP432_NUM_TIMERS 4 |
typedef struct PWMTimerMSP432_HWAttrs PWMTimerMSP432_HWAttrs |
PWMTimerMSP432 Hardware attributes.
These fields are used by driverlib APIs and therefore must be populated by driverlib macro definitions. For MSP430Ware these definitions are found in:
A sample structure is shown below:
typedef struct PWMTimerMSP432_Status PWMTimerMSP432_Status |
The application must not access any member variables of this structure!
typedef struct PWMTimerMSP432_Object PWMTimerMSP432_Object |
PWMTimerMSP432 Object.
The application must not access any member variables of this structure!
const PWM_FxnTable PWMTimerMSP432_fxnTable |