Overview of Creating Models for C2000 Processors

Accessing the Embedded Coder Block Library

  1. After you have installed the supported development board, start MATLAB®.

  2. Open the c2000lib blockset in the Simulink® library browser, or type in the following command at the MATLAB command prompt:

    c2000lib
    
  3. Create your real-time model for your application the same way you create other Simulink models. Select blocks to build your model from the following sources or products:

    • The libraries in the c2000lib block library (for handling input and output functions for on your target hardware)

    • Simulink Coder™ software

    • Discrete time blocks from Simulink

    • Another blockset that meets your needs and operates in the discrete time domain

Note

Rapid Accelerator simulation is not supported by Embedded Coder® Support Package for Texas Instruments™ C2000™ Processors.

Building Your Model

With this configuration, you can generate a real-time executable and download it to your Texas Instruments development board. Simulink Coder software automatically generates C code and inserts the I/O device drivers as specified by the hardware blocks in your block diagram. These device drivers are inserted in the generated C code.

When you are creating a custom device driver block using S-function, use the MATLAB_MEX_FILE macro to differentiate between simulation and code generation behaviors. For example, when you include the Texas Instruments header file in the generated code for creating the MEX file, use the #else section to avoid compilation errors, as shown:

#ifdef MATLAB_MEX_FILE /*
/* Simulation behavior */
#else
/* Code generation behavior*/
#endif

During the build operation, the Texas Instruments cross-compiler builds an executable file from the generated code. If you select the Build, load and run option in Hardware Implementation > Target Hardware Resources > Build options > Build action parameter then the generated executable is automatically downloaded to the target. For CCS v5 and the later versions, a CCS project file is also generated during the build process. You can use this project file for debugging in the CCS IDE.