TI-RTOS Drivers  tidrivers_full_2_20_00_08
Data Structures | Macros | Typedefs | Variables
PWMTiva.h File Reference

Detailed Description

PWM driver implementation for Tiva PWM peripherals.

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

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.

Operation

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 controlling 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 responsible 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:

After opening, the PWM_setPeriodl() 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, so the period must be larger than both duties. The equation below can be used to determine the prescalar for a given period (the prescalar will be the following power of 2 (2^x)):

#include <stdbool.h>
#include <ti/drivers/PWM.h>
Include dependency graph for PWMTiva.h:

Go to the source code of this file.

Data Structures

struct  PWMTiva_HWAttrsV1
 PWMTiva Hardware attributes. More...
 
struct  PWMTiva_Status
 PWMTiva_Status. More...
 
struct  PWMTiva_Object
 PWMTiva Object. More...
 

Macros

#define PWMTiva_NUM_PWM_PERIPHERALS   (2)
 
#define PWMTiva_NUM_PWM_GENERATORS   (4)
 
#define PWMTiva_NUM_PWM_OUTPUTS   (8)
 

Typedefs

typedef struct PWMTiva_HWAttrsV1 PWMTiva_HWAttrsV1
 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
 

Macro Definition Documentation

#define PWMTiva_NUM_PWM_PERIPHERALS   (2)
#define PWMTiva_NUM_PWM_GENERATORS   (4)
#define PWMTiva_NUM_PWM_OUTPUTS   (8)

Typedef Documentation

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:

  • inc/hw_memmap.h
  • driverlib/gpio.h
  • driverlib/pwm.h

A sample structure is shown below:

1 const PWMTiva_HWAttrs PWMTivaHWAttrs[] = {
2  {
3  .pwmBaseAddr = PWM0_BASE,
4  .pwmOutput = PWM_OUT_0,
5  .pwmGenOpts = PWM_GEN_MODE_DOWN | PWM_GEN_MODE_DBG_RUN,
6  .pinPwmMode = GPIO_PF0_M0PWM0,
7  .gpioBaseAddr = GPIO_PORTF_BASE,
8  .gpioPinIndex = GPIO_PIN_0
9  }
10 };

PWMTiva_Status.

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

PWMTiva Object.

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

Variable Documentation

const PWM_FxnTable PWMTiva_fxnTable
Copyright 2016, Texas Instruments Incorporated