TI-RTOS Drivers  tidrivers_tivac_2_16_00_08
Data Structures | Macros | Typedefs | Variables
PWMTimerTiva.h File Reference

Detailed Description

PWM driver implementation using Tiva General Purpose Timer 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 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:

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

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>
Include dependency graph for PWMTimerTiva.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_CMD_CHANGE_PERIOD   PWM_CMD_RESERVED + 0
 Control command to change the PWM period. More...
 
#define PWMTimerTiva_CHANGE_PERIOD   PWMTimerTiva_CMD_CHANGE_PERIOD
 

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
 

Macro Definition Documentation

#define PWMTimerTiva_CHANGE_PERIOD   PWMTimerTiva_CMD_CHANGE_PERIOD

Typedef Documentation

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:

  • inc/hw_memmap.h
  • driverlib/timer.h

A sample structure is shown below:

1 const PWMTimerTiva_HWAttrs PWMTimerTivaHWAttrs[] = {
2  {
3  .baseAddr = TIMERA3_BASE,
4  .timer = TIMER_A
5  },
6  {
7  .baseAddr = TIMERA3_BASE,
8  .timer = TIMER_B
9  },
10 };

PWMTimerTiva Object.

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

Variable Documentation

const PWM_FxnTable PWMTimerTiva_fxnTable
Copyright 2016, Texas Instruments Incorporated