Data Structures | Variables
PWMTimerMSP432.h File Reference

Detailed Description

PWM driver implementation using MSP432 Timer_A peripherals.


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

Overview

This driver configures a MSP432 Timer_A peripheral for PWM. If the timer is already in use (by the kernel for instance), PWM instances will not be opened.

When used for PWM generation, each Timer_A can produce up to 6 PWM outputs and this driver manages each output as an independent PWM instance. However since a single period, prescalar, and clock source are used for all PWM outputs, there are limitations in place to ensure proper operation:

The timer is automatically configured in count-up mode using the clock source specified in the hwAttrs structure. In PWM mode, the timer 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:

After opening, the PWM_setPeriod() API can be used to change the PWM period. Keep in mind the period is shared by all other PWMs on the timer, so all other PWM outputs on the timer will change.

MPS432 PWM Driver Configuration

In order to use the PWM APIs, the application is required to define 4 configuration items in the application ti_drivers_config.c file:

  1. An array of PWMTimerMSP432_Object elements, which will be used by by the driver to maintain instance state. Below is an example PWMTimerMSP432_Object array appropriate for the MSP432 LaunchPad board:
    #include <ti/drivers/PWM.h>
    PWMTimerMSP432_Object pwmTimerMSP432Objects[2];
  2. An array of PWMTimerMSP432_HWAttrsV2 elements that defines which pin will be used by the corresponding PWM instance (see PWMTimerMSP432_HWAttrs 'pwmPin' field options). Below is an example PWMTimerMSP432_HWAttrsV2 array appropriate for the MSP432 LaunchPad board:
    const PWMTimerMSP432_HWAttrsV2 pwmTimerMSP432HWAttrs[2] = {
    {
    .clockSource = TIMER_A_CLOCKSOURCE_SMCLK,
    },
    {
    .clockSource = TIMER_A_CLOCKSOURCE_SMCLK,
    }
    };
  3. An array of PWM_Config elements, one for each PWM instance. Each element of this array identifies the device-specific API function table, the device specific PWM object instance, and the device specific Hardware Attributes to be used for each PWM channel. Below is an example PWM_Config array appropriate for the MSP432 LaunchPad board:
    const PWM_Config PWM_config[2] = {
    {
    .object = &pwmTimerMSP432Objects[0],
    .hwAttrs = &pwmTimerMSP432HWAttrs[0]
    },
    {
    .fxnTablePtr = &PWMTimerMSP432_fxnTable,
    .object = &pwmTimerMSP432Objects[1],
    .hwAttrs = &pwmTimerMSP432HWAttrs[1]
    }
    };
  4. A global variable, PWM_count, that informs the driver how many PWM instances are defined:
    const uint_least8_t PWM_count = 2;

Resource Allocation

Allocation of each timer peripheral is managed through a set of resource allocation APIs. For example, the TimerMSP432_allocateTimerResource API will allocate a timer for exclusive use. Any attempt to allocate this resource in the future will result in a false value being returned from the allocation API. To free a timer resource, the TimerMSP432_freeTimerResource is used. The application is not responsible for calling these allocation APIs directly.

Power Management

The TI-RTOS power management framework will try to put the device into the most power efficient mode whenever possible. Please see the technical reference manual for further details on each power mode.

This driver supports dynamic power performance levels. The driver will determine which power performance levels are compatible with the desired period and period units. The driver prevents transitions to performance levels in which the period cannot be generated. When PWM_setPeriod() is called, the compatible performance levels are re-calculated and set.

After a performance level change, the period is recalculated such that the generated period will remain the same. The duty cycle is not recalculated. The application is responsible for calling PWM_setDuty() after a performance level change. The exact period may vary after a performance level transition. This is due to a change in clock frequency and hence period per clock cycle.

PWM_stop(pwmHandle);
// Change performance level code
PWM_setDuty(pwmHandle, duty);
PWM_start(pwmHandle);

The following statements are valid:

#include <stdbool.h>
#include <ti/devices/DeviceFamily.h>
#include <ti/drivers/Power.h>
#include <ti/drivers/PWM.h>
#include <ti/devices/msp432p4xx/driverlib/pmap.h>
#include <ti/devices/msp432p4xx/driverlib/timer_a.h>
Include dependency graph for PWMTimerMSP432.h:

Go to the source code of this file.

Data Structures

struct  PWMTimerMSP432_HWAttrsV2
 PWMTimerMSP432 Hardware attributes. More...
 
struct  PWMTimerMSP432_Status
 PWMTimerMSP432_Status. More...
 
struct  PWMTimerMSP432_Object
 PWMTimerMSP432 Object. More...
 

Macros

Port 2, Pin 0 'pwmPin' setting variations
#define PWMTimerMSP432_P2_0_TA0CCR1A
 
#define PWMTimerMSP432_P2_0_TA0CCR2A
 
#define PWMTimerMSP432_P2_0_TA0CCR3A
 
#define PWMTimerMSP432_P2_0_TA0CCR4A
 
#define PWMTimerMSP432_P2_0_TA1CCR1A
 
#define PWMTimerMSP432_P2_0_TA1CCR2A
 
#define PWMTimerMSP432_P2_0_TA1CCR3A
 
#define PWMTimerMSP432_P2_0_TA1CCR4A
 
Port 2, Pin 1 'pwmPin' setting variations
#define PWMTimerMSP432_P2_1_TA0CCR1A
 
#define PWMTimerMSP432_P2_1_TA0CCR2A
 
#define PWMTimerMSP432_P2_1_TA0CCR3A
 
#define PWMTimerMSP432_P2_1_TA0CCR4A
 
#define PWMTimerMSP432_P2_1_TA1CCR1A
 
#define PWMTimerMSP432_P2_1_TA1CCR2A
 
#define PWMTimerMSP432_P2_1_TA1CCR3A
 
#define PWMTimerMSP432_P2_1_TA1CCR4A
 
Port 2, Pin 2 'pwmPin' setting variations
#define PWMTimerMSP432_P2_2_TA0CCR1A
 
#define PWMTimerMSP432_P2_2_TA0CCR2A
 
#define PWMTimerMSP432_P2_2_TA0CCR3A
 
#define PWMTimerMSP432_P2_2_TA0CCR4A
 
#define PWMTimerMSP432_P2_2_TA1CCR1A
 
#define PWMTimerMSP432_P2_2_TA1CCR2A
 
#define PWMTimerMSP432_P2_2_TA1CCR3A
 
#define PWMTimerMSP432_P2_2_TA1CCR4A
 
Port 2, Pin 3 'pwmPin' setting variations
#define PWMTimerMSP432_P2_3_TA0CCR1A
 
#define PWMTimerMSP432_P2_3_TA0CCR2A
 
#define PWMTimerMSP432_P2_3_TA0CCR3A
 
#define PWMTimerMSP432_P2_3_TA0CCR4A
 
#define PWMTimerMSP432_P2_3_TA1CCR1A
 
#define PWMTimerMSP432_P2_3_TA1CCR2A
 
#define PWMTimerMSP432_P2_3_TA1CCR3A
 
#define PWMTimerMSP432_P2_3_TA1CCR4A
 
Port 2, Pin 4 'pwmPin' setting variations
#define PWMTimerMSP432_P2_4_TA0CCR1A
 
#define PWMTimerMSP432_P2_4_TA0CCR2A
 
#define PWMTimerMSP432_P2_4_TA0CCR3A
 
#define PWMTimerMSP432_P2_4_TA0CCR4A
 
#define PWMTimerMSP432_P2_4_TA1CCR1A
 
#define PWMTimerMSP432_P2_4_TA1CCR2A
 
#define PWMTimerMSP432_P2_4_TA1CCR3A
 
#define PWMTimerMSP432_P2_4_TA1CCR4A
 
Port 2, Pin 5 'pwmPin' setting variations
#define PWMTimerMSP432_P2_5_TA0CCR1A
 
#define PWMTimerMSP432_P2_5_TA0CCR2A
 
#define PWMTimerMSP432_P2_5_TA0CCR3A
 
#define PWMTimerMSP432_P2_5_TA0CCR4A
 
#define PWMTimerMSP432_P2_5_TA1CCR1A
 
#define PWMTimerMSP432_P2_5_TA1CCR2A
 
#define PWMTimerMSP432_P2_5_TA1CCR3A
 
#define PWMTimerMSP432_P2_5_TA1CCR4A
 
Port 2, Pin 6 'pwmPin' setting variations
#define PWMTimerMSP432_P2_6_TA0CCR1A
 
#define PWMTimerMSP432_P2_6_TA0CCR2A
 
#define PWMTimerMSP432_P2_6_TA0CCR3A
 
#define PWMTimerMSP432_P2_6_TA0CCR4A
 
#define PWMTimerMSP432_P2_6_TA1CCR1A
 
#define PWMTimerMSP432_P2_6_TA1CCR2A
 
#define PWMTimerMSP432_P2_6_TA1CCR3A
 
#define PWMTimerMSP432_P2_6_TA1CCR4A
 
Port 2, Pin 7 'pwmPin' setting variations
#define PWMTimerMSP432_P2_7_TA0CCR1A
 
#define PWMTimerMSP432_P2_7_TA0CCR2A
 
#define PWMTimerMSP432_P2_7_TA0CCR3A
 
#define PWMTimerMSP432_P2_7_TA0CCR4A
 
#define PWMTimerMSP432_P2_7_TA1CCR1A
 
#define PWMTimerMSP432_P2_7_TA1CCR2A
 
#define PWMTimerMSP432_P2_7_TA1CCR3A
 
#define PWMTimerMSP432_P2_7_TA1CCR4A
 
Port 3, Pin 0 'pwmPin' setting variations
#define PWMTimerMSP432_P3_0_TA0CCR1A
 
#define PWMTimerMSP432_P3_0_TA0CCR2A
 
#define PWMTimerMSP432_P3_0_TA0CCR3A
 
#define PWMTimerMSP432_P3_0_TA0CCR4A
 
#define PWMTimerMSP432_P3_0_TA1CCR1A
 
#define PWMTimerMSP432_P3_0_TA1CCR2A
 
#define PWMTimerMSP432_P3_0_TA1CCR3A
 
#define PWMTimerMSP432_P3_0_TA1CCR4A
 
Port 3, Pin 1 'pwmPin' setting variations
#define PWMTimerMSP432_P3_1_TA0CCR1A
 
#define PWMTimerMSP432_P3_1_TA0CCR2A
 
#define PWMTimerMSP432_P3_1_TA0CCR3A
 
#define PWMTimerMSP432_P3_1_TA0CCR4A
 
#define PWMTimerMSP432_P3_1_TA1CCR1A
 
#define PWMTimerMSP432_P3_1_TA1CCR2A
 
#define PWMTimerMSP432_P3_1_TA1CCR3A
 
#define PWMTimerMSP432_P3_1_TA1CCR4A
 
Port 3, Pin 2 'pwmPin' setting variations
#define PWMTimerMSP432_P3_2_TA0CCR1A
 
#define PWMTimerMSP432_P3_2_TA0CCR2A
 
#define PWMTimerMSP432_P3_2_TA0CCR3A
 
#define PWMTimerMSP432_P3_2_TA0CCR4A
 
#define PWMTimerMSP432_P3_2_TA1CCR1A
 
#define PWMTimerMSP432_P3_2_TA1CCR2A
 
#define PWMTimerMSP432_P3_2_TA1CCR3A
 
#define PWMTimerMSP432_P3_2_TA1CCR4A
 
Port 3, Pin 3 'pwmPin' setting variations
#define PWMTimerMSP432_P3_3_TA0CCR1A
 
#define PWMTimerMSP432_P3_3_TA0CCR2A
 
#define PWMTimerMSP432_P3_3_TA0CCR3A
 
#define PWMTimerMSP432_P3_3_TA0CCR4A
 
#define PWMTimerMSP432_P3_3_TA1CCR1A
 
#define PWMTimerMSP432_P3_3_TA1CCR2A
 
#define PWMTimerMSP432_P3_3_TA1CCR3A
 
#define PWMTimerMSP432_P3_3_TA1CCR4A
 
Port 3, Pin 4 'pwmPin' setting variations
#define PWMTimerMSP432_P3_4_TA0CCR1A
 
#define PWMTimerMSP432_P3_4_TA0CCR2A
 
#define PWMTimerMSP432_P3_4_TA0CCR3A
 
#define PWMTimerMSP432_P3_4_TA0CCR4A
 
#define PWMTimerMSP432_P3_4_TA1CCR1A
 
#define PWMTimerMSP432_P3_4_TA1CCR2A
 
#define PWMTimerMSP432_P3_4_TA1CCR3A
 
#define PWMTimerMSP432_P3_4_TA1CCR4A
 
Port 3, Pin 5 'pwmPin' setting variations
#define PWMTimerMSP432_P3_5_TA0CCR1A
 
#define PWMTimerMSP432_P3_5_TA0CCR2A
 
#define PWMTimerMSP432_P3_5_TA0CCR3A
 
#define PWMTimerMSP432_P3_5_TA0CCR4A
 
#define PWMTimerMSP432_P3_5_TA1CCR1A
 
#define PWMTimerMSP432_P3_5_TA1CCR2A
 
#define PWMTimerMSP432_P3_5_TA1CCR3A
 
#define PWMTimerMSP432_P3_5_TA1CCR4A
 
Port 3, Pin 6 'pwmPin' setting variations
#define PWMTimerMSP432_P3_6_TA0CCR1A
 
#define PWMTimerMSP432_P3_6_TA0CCR2A
 
#define PWMTimerMSP432_P3_6_TA0CCR3A
 
#define PWMTimerMSP432_P3_6_TA0CCR4A
 
#define PWMTimerMSP432_P3_6_TA1CCR1A
 
#define PWMTimerMSP432_P3_6_TA1CCR2A
 
#define PWMTimerMSP432_P3_6_TA1CCR3A
 
#define PWMTimerMSP432_P3_6_TA1CCR4A
 
Port 3, Pin 7 'pwmPin' setting variations
#define PWMTimerMSP432_P3_7_TA0CCR1A
 
#define PWMTimerMSP432_P3_7_TA0CCR2A
 
#define PWMTimerMSP432_P3_7_TA0CCR3A
 
#define PWMTimerMSP432_P3_7_TA0CCR4A
 
#define PWMTimerMSP432_P3_7_TA1CCR1A
 
#define PWMTimerMSP432_P3_7_TA1CCR2A
 
#define PWMTimerMSP432_P3_7_TA1CCR3A
 
#define PWMTimerMSP432_P3_7_TA1CCR4A
 
Port 5 'pwmPin' setting variations
#define PWMTimerMSP432_P5_6_TA2CCR1A
 
#define PWMTimerMSP432_P5_7_TA2CCR2A
 
Port 6 'pwmPin' setting variations
#define PWMTimerMSP432_P6_6_TA2CCR3A
 
#define PWMTimerMSP432_P6_7_TA2CCR4A
 
Port 7, Pin 0 'pwmPin' setting variations
#define PWMTimerMSP432_P7_0_TA0CCR1A
 
#define PWMTimerMSP432_P7_0_TA0CCR2A
 
#define PWMTimerMSP432_P7_0_TA0CCR3A
 
#define PWMTimerMSP432_P7_0_TA0CCR4A
 
#define PWMTimerMSP432_P7_0_TA1CCR1A
 
#define PWMTimerMSP432_P7_0_TA1CCR2A
 
#define PWMTimerMSP432_P7_0_TA1CCR3A
 
#define PWMTimerMSP432_P7_0_TA1CCR4A
 
Port 7, Pin 1 'pwmPin' setting variations
#define PWMTimerMSP432_P7_1_TA0CCR1A
 
#define PWMTimerMSP432_P7_1_TA0CCR2A
 
#define PWMTimerMSP432_P7_1_TA0CCR3A
 
#define PWMTimerMSP432_P7_1_TA0CCR4A
 
#define PWMTimerMSP432_P7_1_TA1CCR1A
 
#define PWMTimerMSP432_P7_1_TA1CCR2A
 
#define PWMTimerMSP432_P7_1_TA1CCR3A
 
#define PWMTimerMSP432_P7_1_TA1CCR4A
 
Port 7, Pin 2 'pwmPin' setting variations
#define PWMTimerMSP432_P7_2_TA0CCR1A
 
#define PWMTimerMSP432_P7_2_TA0CCR2A
 
#define PWMTimerMSP432_P7_2_TA0CCR3A
 
#define PWMTimerMSP432_P7_2_TA0CCR4A
 
#define PWMTimerMSP432_P7_2_TA1CCR1A
 
#define PWMTimerMSP432_P7_2_TA1CCR2A
 
#define PWMTimerMSP432_P7_2_TA1CCR3A
 
#define PWMTimerMSP432_P7_2_TA1CCR4A
 
Port 7, Pin 3 'pwmPin' setting variations
#define PWMTimerMSP432_P7_3_TA0CCR1A
 
#define PWMTimerMSP432_P7_3_TA0CCR2A
 
#define PWMTimerMSP432_P7_3_TA0CCR3A
 
#define PWMTimerMSP432_P7_3_TA0CCR4A
 
#define PWMTimerMSP432_P7_3_TA1CCR1A
 
#define PWMTimerMSP432_P7_3_TA1CCR2A
 
#define PWMTimerMSP432_P7_3_TA1CCR3A
 
#define PWMTimerMSP432_P7_3_TA1CCR4A
 
Port 7, Pin 4 'pwmPin' setting variations
#define PWMTimerMSP432_P7_4_TA0CCR1A
 
#define PWMTimerMSP432_P7_4_TA0CCR2A
 
#define PWMTimerMSP432_P7_4_TA0CCR3A
 
#define PWMTimerMSP432_P7_4_TA0CCR4A
 
#define PWMTimerMSP432_P7_4_TA1CCR1A
 
#define PWMTimerMSP432_P7_4_TA1CCR2A
 
#define PWMTimerMSP432_P7_4_TA1CCR3A
 
#define PWMTimerMSP432_P7_4_TA1CCR4A
 
Port 7, Pin 5 'pwmPin' setting variations
#define PWMTimerMSP432_P7_5_TA0CCR1A
 
#define PWMTimerMSP432_P7_5_TA0CCR2A
 
#define PWMTimerMSP432_P7_5_TA0CCR3A
 
#define PWMTimerMSP432_P7_5_TA0CCR4A
 
#define PWMTimerMSP432_P7_5_TA1CCR1A
 
#define PWMTimerMSP432_P7_5_TA1CCR2A
 
#define PWMTimerMSP432_P7_5_TA1CCR3A
 
#define PWMTimerMSP432_P7_5_TA1CCR4A
 
Port 7, Pin 6 'pwmPin' setting variations
#define PWMTimerMSP432_P7_6_TA0CCR1A
 
#define PWMTimerMSP432_P7_6_TA0CCR2A
 
#define PWMTimerMSP432_P7_6_TA0CCR3A
 
#define PWMTimerMSP432_P7_6_TA0CCR4A
 
#define PWMTimerMSP432_P7_6_TA1CCR1A
 
#define PWMTimerMSP432_P7_6_TA1CCR2A
 
#define PWMTimerMSP432_P7_6_TA1CCR3A
 
#define PWMTimerMSP432_P7_6_TA1CCR4A
 
Port 7, Pin 7 'pwmPin' setting variations
#define PWMTimerMSP432_P7_7_TA0CCR1A
 
#define PWMTimerMSP432_P7_7_TA0CCR2A
 
#define PWMTimerMSP432_P7_7_TA0CCR3A
 
#define PWMTimerMSP432_P7_7_TA0CCR4A
 
#define PWMTimerMSP432_P7_7_TA1CCR1A
 
#define PWMTimerMSP432_P7_7_TA1CCR2A
 
#define PWMTimerMSP432_P7_7_TA1CCR3A
 
#define PWMTimerMSP432_P7_7_TA1CCR4A
 
Port 8, 'pwmPin' setting variations
#define PWMTimerMSP432_P8_2_TA3CCR2A
 
Port 9 'pwmPin' setting variations
#define PWMTimerMSP432_P9_2_TA3CCR3A
 
#define PWMTimerMSP432_P9_3_TA3CCR4A
 
Port 10 'pwmPin' setting variations
#define PWMTimerMSP432_P10_5_TA3CCR1A
 

Variables

const PWM_FxnTable PWMTimerMSP432_fxnTable
 

Variable Documentation

§ PWMTimerMSP432_fxnTable

const PWM_FxnTable PWMTimerMSP432_fxnTable
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale