TI-RTOS for SimpleLink Wireless MCUs  2.14.03.28
Data Structures | Macros | Typedefs | Variables
PWMTimerMSP432.h File Reference

Detailed Description

PWM driver implementation.

============================================================================

The PWM header file should be included in an application as follows:

Operation

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:

  1. The PWM period and prescalar are calculated and set based on the first instance opened. Opening a second instance will fail if the period is not the same as what was set by the first instance.

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:

int rc = 0;
int newPeriod = 6000; // Period in microseconds
rc = PWM_control(pwmHandle, PWMTimerMSP432_CHANGE_PERIOD, &newPeriod);
if (rc < 0) {
// handle error condition
}

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>
Include dependency graph for PWMTimerMSP432.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_NUM_TIMERS   4
 
#define PWMTimerMSP432_CHANGE_PERIOD   PWM_CMD_RESERVED + 0
 

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
 

Macro Definition Documentation

#define PWMTimerMSP432_NUM_TIMERS   4
#define PWMTimerMSP432_CHANGE_PERIOD   PWM_CMD_RESERVED + 0

Typedef Documentation

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:

  • timer_a.h

A sample structure is shown below:

1 const PWMTimerMSP432_HWAttrs PWMTimerMSP432HWAttrs[] = {
2  {
3  .baseAddr = TIMER_A0_BASE,
4  .compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1
5  },
6 };

PWMTimerMSP432_Status.

The application must not access any member variables of this structure!

PWMTimerMSP432 Object.

The application must not access any member variables of this structure!

Variable Documentation

const PWM_FxnTable PWMTimerMSP432_fxnTable
Copyright 2015, Texas Instruments Incorporated