Main Content

Use C2000 blocks with Multiprocessor Modeling

You can use the C2000™ Microcontroller Blockset blocks with multiprocessor.

Multiprocessor blocks that interact with external hardware (for example ADC or PWM) come in pairs. The pair consists of a data input or output block, such as ADC Read (SoC Blockset), that simulates the behavior of the software drivers and an interface block, such as ADC Interface (SoC Blockset), that simulates the physical behavior of the hardware. During code generation, the data input or output block becomes the driver code for the given hardware peripheral and the interface block gets removed and replaced by the actual device hardware.

C2000 Microcontroller Blockset blocks are equivalent to the data input or output block with the multiprocessor block pairs. In code generation, the blockset generate the appropriate driver code. In simulation, due to the lack of an interface pair, the blocks do not generate any data and can be treated equivalent to the Constant block for input blocks or the Terminator block for output blocks.

Note

You can add a simulation behavior by using Variant Subsystem, Variant Model block.

Add Embedded Coder into Task

To configure an multiprocessor model to use the C2000 Microcontroller Blockset driver blocks, follow these steps.

  1. Create a new multiprocessor model and set the Hardware board parameter to TI F2837D Launchpad.

  2. Construct an empty event driven task that is driven by an ADC Interface (SoC Blockset) block. This figure shows the sample model.

    SoC model top level

    SoC model ref level

  3. In the Simulink® library browser, from the C2000 Microcontroller Blockset > F2837xD group, add the ADC block to the task in the model.

    SoC task with ADC block

  4. In the ADC block, set the trigger source parameter to Software.

  5. Launch the Hardware Mapping tool. Set the ADC_Task parameter to ADCA1_isr. This setting maps the ADCA1_isr interrupt to the task containing the ADC block.

  6. Use the SoC Builder (SoC Blockset) tool to deploy the model to the connected TI F2837D Launchpad. The ADC block can now sample the ADCs from the hardware.

Link Embedded Coder Interrupts to Events

To configure an multiprocessor model to generate interrupts mapped to the C2000 Microcontroller Blockset blocks, follow these steps.

  1. Create a new multiprocessor model and set the Hardware board parameter to TI F2837D Launchpad.

  2. Construct an empty event driven task that is driven by an ADC Interface (SoC Blockset) block. This figure shows the sample model.

    SoC model top level

    SoC model ref level

  3. In the Simulink library browser, from the C2000 Microcontroller Blockset > F2837xD group, add the ADC block to the task in the model.

    SoC task with ADC block

  4. In the ADC block, set the trigger source parameter to Software.

  5. Launch the Hardware Mapping tool. Set the ADC_Task parameter to ADCA1_isr. This maps the ADCA1_isr interrupt to the task containing the ADC block.

    Task mapping interrupts

  6. Use the SoC Builder (SoC Blockset) tool to deploy the model to the connected TI F2837D Launchpad. The ADC blocks can now samples the ADCs from the hardware on the specified interrupt.

This table shows the mapping between the interrupts in the C2000 Microcontroller Blockset blocks and the interrupts in the Hardware Mapping (SoC Blockset) tool.

Interrupt TypeBlock Interrupt ParameterTask Mapping Interrupt Parameter
Analog to Digital Converter (ADC)ADCAnADCAn_isr
Pulse Width Modulator (PWM)EPWMn_TZEPWMn_TZ_isr
EPWMnEPWMn_isr
Electrically Evoked Compound Action Potential (ECAP)ECAPnECAPn_isr
Enhanced Quadrature Encoder Pulse (eQEP)EQEPnEQEPn_isr
Serial Peripheral Interface (SPI)SPIA_RX_isrSPIA_RX_isr
SPIA_TX_isrSPIA_TX_isr
Direct Memory Address (DMA)DMA_CHnDMA_CHn_isr
Inter-Integrated Circuit (I2C)I2CAI2CA_INT_isr
I2CA_FIFOI2CA_FIFO_isr
Serial Communication Interface (SCI)SCIA_RXSCIA_RX_isr
SCIA_TXSCIA_TX_isr
Controller Area Network (CAN)CANA_nCANA_n_isr
External Interrupt (XINT)XINTnXINTn_isr
Fixed Point Unit (FPU)FPU_OVERFLOWFPU_OVERFLOW_isr
FPU_UNDERFLOWFPU_UNDERFLOW_isr
Viterbi, Complex Math, and CRC Unit (VCU)VCUVCU_isr

See Also

(SoC Blockset) | (SoC Blockset) |