| Contents | Index |
Embedded Coder/ Embedded Targets/ Processors/ Texas Instruments C2000/ C281x
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.
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
0 — The FIFO is empty. Either no captures have occurred or the previously stored captures have been read from the stack. (The binary version of this flag is 00.)
1 — The FIFO has one entry in the top register of the stack. (The binary version of this flag is 01.)
2 — The FIFO has two entries in the stack registers. (The binary version of this flag is 10.)
3 — The FIFO has two entries in the stack registers and one or more captured values have been lost. This occurs because another capture occurred before the FIFO stack was read. The new value is placed in the bottom register. The bottom register value is pushed to the top of the stack and the top value is pushed out of the stack. (The binary version of this flag is 11.)

Select the Event Manager (EV) module to use:
A — Use CAPs 1, 2, and 3.
B — Use CAPs 4, 5, and 6.
Select to output the status of the elements in the FIFO. The data type of the status flag is uint16.
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:
The CAP x FIFO status bits are read and the value is stored in the status flag.
The top value of the FIFO is read and stored in the output at index 0.
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:
The CAP x FIFO status bits are read and the value is stored in the status flag.
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:
The CAP x FIFO status bits are read and the value is stored in the status flag.
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.
Time between outputs from the FIFO. If new data is not available, the previous data is sent.
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.

The CAP panes set parameters for individual CAPs. The particular CAP affected by a CAP pane depends on the EV module you selected:
CAP1 controls CAP 1 or CAP 4, for EV module A or B, respectively.
CAP2 controls CAP 2 or CAP 5, for EV module A or B, respectively.
CAP3 controls CAP 3 or CAP 6, for EV module A or B, respectively.
Select to use the specified capture unit pin.
Type of transition detection to use for this CAP. Available types are Rising Edge, Falling Edge, Both Edges, and No transition.
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.
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.
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.
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 |
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.
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.
Check this check box to post an asynchronous interrupt on CAP.

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 |