Main Content

Sharing General Purpose Timers Between C281x Peripherals

TMS320x281x DSP devices have four General Purpose (GP) timers. Each Event Manager (EV) module includes two GP timers:

  • EVA includes GP Timer 1 and GP Timer 2.

  • EVB includes GP Timer 3 and GP Timer 4.

You can use the GP Timers independently or to operate peripherals associated with the EV Manager, such as PWM, QEP, and CAP.

The following table describes the timer-peripheral mapping of the c281xlib block library.

GP Timer Use for C281x Peripheral Blocks

 GP Timer 1GP Timer 2GP Timer 3GP Timer 4
PWM1-PWM6   
PWM7-PWM12   
QEP1-QEP2   
QEP3-QEP4   
CAP1-CAP3  
CAP4-CAP6  

Each PWM or QEP peripheral has access to only one timer, while each CAP peripheral has access to two timers. In the PWM and QEP blocks, you can set the Module option to A or B to determine which unique timer-peripheral combination the block configures. By comparison, in the CAP block, you can use the Time base option to select one of two timers for each CAP peripheral.

Each GP timer is available to multiple peripherals. For example:

  • PWM1-PWM6 and CAP1-CAP3 share GP Timer 1

  • PWM7-PWM12 and CAP4-CAP6 share GP Timer 3

  • QEP1-QEP2 and CAP1-CAP3 share GP Timer 2

  • QEP3-QEP4 and CAP4-CAP6 share GP Timer 4

The PWM, QEP, CAP, and Timer blocks each provide independent access to key timer registers. If the blocks in your model share a specific GP timer, check that the timer-related settings are compatible. If the peripheral settings for a shared timer are not compatible, the software generates an error when you update the model or generate code.

Sharing General Purpose Timers Between CAP and CAN

CAP and eCAN

The model contains Timer and CAP blocks that both use Timer 1 (GP Timer 1).

Timer block mask

Both blocks have the same values for Timer prescaler and Counting mode. However, each block has different values for Timer period. The value of Timer period for Timer 1 is 65535 in the CAP block and 10000 in the Timer block.

Timer sharing algorithm

Since both blocks configure the same timer, and settings conflict, the software generates an error when you update the model.

Sharing General Purpose Timers Between CAP and SPI

CAP and SPI

The model contains QEP and CAP blocks that both use Timer 2. In the CAP block, the Time base option shows which timer the block uses. In the QEP block, setting Module to A configures the block to use QEP1–QEP2. GP Timer Use for C281x Peripheral Blocks shows that QEP1–QEP2 use Timer 2.

CAP block mask

QEP block

Currently, both blocks define different clock sources for Timer 2. The CAP block uses Internal as a Clock source. The QEP block, which does not have a configurable Clock source setting, uses the QEP circuit as a clock source. If you build the model, the software generates the following error message.

timer sharing

To avoid generating errors when you build the model, change Clock source in the CAP block to QEP device.