Skip to Main Content Skip to Search
Product Documentation

C281x CAP - Receive and log capture input pin transitions

Library

Embedded Coder/ Embedded Targets/ Processors/ Texas Instruments C2000/ C281x

Description

The C281x CAP block sets parameters for the capture units (CAPs) of the Event Manager (EV) module. The capture units log transitions detected on the capture unit pins by recording the times of these transitions into a two-level deep FIFO stack. You can set the capture unit pins to detect rising edge, falling edge, either type of transition, or no transition.

The C281x chip has six capture units — three associated with each EV module. Capture units 1, 2, and 3 are associated with EVA and capture units 4, 5, and 6 are associated with EVB. Each capture unit is associated with a capture input pin.

Each group of EV module capture units can use one of two general-purpose (GP) timers on the target board. EVA capture units can use GP timer 1 or 2. EVB capture units can use GP timer 3 or 4. When a transition occurs, the module stores the value of the selected timer in the two-level deep FIFO stack.

The C281x CAP module shares GP Timers with other C281 blocks. For more information and guidance on sharing timers, see Sharing General Purpose Timers between C281x Peripherals.

Outputs

This block has up to two outputs: a cnt (count) output and an optional, FIFO status flag output. The cnt output increments each time a transition of the selected type occurs. The status flag outputs are

Dialog Box

Data Format Pane

Module

Select the Event Manager (EV) module to use:

  • A — Use CAPs 1, 2, and 3.

  • B — Use CAPs 4, 5, and 6.

Output overrun status flag

Select to output the status of the elements in the FIFO. The data type of the status flag is uint16.

Send data format

The type of data to output:

  • Send 2 elements (FIFO Buffer) — Sends the latest two values. The output is updated when there are two elements in the FIFO, which is indicated by bit 13 or 11 or 9 being sent (CAP x FIFO). If the CAP is polled when fewer than two elements are captures, old values are repeated. The CAP registers are read as follows:

    1. The CAP x FIFO status bits are read and the value is stored in the status flag.

    2. The top value of the FIFO is read and stored in the output at index 0.

    3. The new top value of the FIFO (the previously stored bottom stack value) is read and stored in the output at index 1.

  • Send 1 element (oldest) — Sends the older of the two most recent values. The output is updated when there is at least one element in the FIFO, which is indicated by any of the bits 13:12, or 11:10, or 9:8 being sent. The CAP registers are read as follows:

    1. The CAP x FIFO status bits are read and the value is stored in the status flag.

    2. The top value of the FIFO is read and stored in the output.

  • Send 1 element (latest) — Sends the most recent value. The output is updated when there is at least one element in the FIFO, which is indicated by any of the bits 13:12, or 11:10, or 9:8 being sent. The CAP registers are read as follows:

    1. The CAP x FIFO status bits are read and the value is stored in the status flag.

    2. If there are two entries in the FIFO, the bottom value is read and stored in the output. If there is only one entry in the FIFO, the top value is read and stored in the output.

Sample time

Time between outputs from the FIFO. If new data is not available, the previous data is sent.

Data type

Data type of the output data. Available options are auto, double, single, int8, uint8, int16, uint16, int32, uint32, and boolean. The auto option uses the data type of a connected block that outputs data to this block. If this block does not receive any input, auto sets the data type to double.

    Note   The output of the C281x CAP block can be vectorized.

CAP Panes

The CAP panes set parameters for individual CAPs. The particular CAP affected by a CAP pane depends on the EV module you selected:

Enable CAP

Select to use the specified capture unit pin.

Edge Detection

Type of transition detection to use for this CAP. Available types are Rising Edge, Falling Edge, Both Edges, and No transition.

Time Base

Select which target board GP timer the CAP uses as a time base. CAPs 1, 2, and 3 can use Timer 1 or Timer 2. CAPs 4, 5, and 6 can use Timer 3 or Timer 4.

Clock source

This option is available only for the CAP 3 pane. You can select Internal to use the internal time base. Also configure the Counting mode, Timer prescaler, and Timer period source for the internal time base.

Select QEP circuit to generate the input clock from the quadrature encoder pulse (QEP) submodule.

Counting mode

Select Up to generate an asymmetrical waveform output, or Up-down to generate a symmetrical waveform output, as shown in the following illustration.

When you specify the Counting mode as Up (asymmetric) the waveform:

  • Starts low

  • Goes high when the rising period counter value matches the Compare value

  • Goes low at the end of the period

When you specify the Counting mode as Up-down (symmetric) the waveform:

  • Starts low

  • Goes high when the increasing period counter value matches the Compare value

  • Goes low when the decreasing period counter value matches the Compare value

Counting mode becomes unavailable when you set Clock source to QEP circuit.

Timer Prescaler

Clock divider factor by which to prescale the selected GP timer to produce the desired timer counting rate. Available options are none, 1/2, 1/4, 1/8, 1/16, 1/32, 1/64, and 1/128. The following table shows the rates that result from selecting each option.

Scaling

Resulting Rate (µs)

none

0.01334

1/2

0.02668

1/4

0.05336

1/8

0.10672

1/16

0.21344

1/32

0.42688

1/64

0.85376

1/128

1.70752

    Note   These rates assume a 75 MHz input clock.

Timer period source

Select Specify via dialog to enable the Timer period parameter. Select Input port to create a block input, T1, that accepts the timer period value.

Timer period

Set the length of the timer period in clock cycles. Enter a value from 0 to 65535. The value defaults to 65535.

If you know the length of a clock cycle, you can easily calculate how many clock cycles to set for the timer period. The following calculation determines the length of one clock cycle:

In this calculation, you divide the System clock frequency of 150 MHz by the high-speed clock prescaler of 2. Then, you divide the resulting value by the timer control input clock prescaler, 128. The resulting frequency is 0.586 MHz. Thus, one clock cycle is 1/.586 MHz, which is 1.706 µs.

Post interrupt on CAP

Check this check box to post an asynchronous interrupt on CAP.

See Also

C281x Hardware Interrupt

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS