This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[FAQ] Sticky: MathWorks Solutions for C2000 MCU’s

Other Parts Discussed in Thread: TMS320F28335, CONTROLSUITE, TMS320F28035, TMDSDOCK28379D, LAUNCHXL-F28379D, TMS320F28379D, TMS320F28379S

Save design time and get into production faster with C2000 MCU’s with MathWorks solutions.

To begin you use MATLAB® and Simulink® to create and simulate your algorithms. Next you use Embedded Coder® to generate production code of your algorithms. Embedded Coder support for Texas Instruments C2000 includes:

        • Automated build and execution
        • Block libraries for on-chip and on-board peripherals such as ADC, digital I/O, ePWM, SPI, I2C, and more
        • Real-time parameter tuning and logging using external mode
        • Processor optimized code including DMC and IQMath libraries
        • Ability to perform processor-in-the-loop (PIL) tests with execution profiling
        • Examples for motor control and power conversion that run on TI C2000 hardware

You can also generate code that runs on the Control Law Accelerator (CLA), a co-processor available on select TI Delfino and Piccolo processors.

For multicore systems, you can use SoC Blockset with C2000 Support for SoC Blockset to build your system architecture using processor, inter-processor communication, interrupt and I/O models, and simulate the architecture together with the algorithms. This allows you to partition algorithms between multiple cores to achieve design modularity and improve performance, and to account for issues like ADC-PWM synchronization and latency.


From within MATLAB you can access hardware support for Embedded Coder via the Add-On Explorer from the MATLAB toolstrip.


Search for C2000, and select to download and install free C2000 library blocks. You insert and configure the blocks, which include IO and various functions, in your Simulink model. Then you use Embedded Coder to generate production code of your algorithm and run it directly on your TI C2000 MCU. The library blocks include documentation, example models, and support C2000 Piccolo, Delfino, and Concerto families.

Note: Using Embedded Coder requires additional MathWorks software: MATLAB®, Simulink®, MATLAB Coder™, and Simulink Coder™.

You can also just generate production code of your algorithms which can be imported and integrated into an existing Code Composer Studio project.

--- ---

Here is more info including how-to videos and examples you can run with TI hardware kits:


    • Details and Examples:

      • C2000 Hardware Support webpages:

      • Delfino: F2833x, F2837xS, F2837xD, C2834x

      • Piccolo: F2802x, F2803x, F2805x, F2806x, F2807x, F28004x

      • Concerto: F28M35x, F28M36x (C28x + ARM Cortex M3)

      • Legacy: C280x, C281x, C2833x, F281x, F280x

      • C2000-Based Examples


Content Updated 2020-11-02

  • Chris,

    Thank you for the information! In what instances should we ask for help in the TI e2e forum and when should we ask for help in the mathworks forum?


  • In almost all cases you will get better results by asking The Mathworks directly.
    I've sent this post to the Mathworks team who supports C2000 and have asked them to follow so that they will receive all questions in an email.

    So feel free to use this thread to ask a simple question.
    If more involved I would post your own thread and use this one to notify The Mathworks.
  • Thank you Chris for this much required thread :)

  • Great to see this info get posted!

    The main link for MathWorks Support is:

    There is C2000 info in Documentation, Examples, and MATLAB Answers.


    I am also happy to try and answer questions on using MathWorks software with C2000 MCU's in these forums.




  • MathWorks Release R2016a is now available to customers, and includes new features for our TI C2000 solution.

    1) F28379 Support: Device is now available in the drop down menu.

    2) Serial SCI Support: New library blocks for SCI Transmit and SCI Receive on TI C2000 F2807x and TI C2000 F2837x processors for asynchronous serial digital communication.

    3) CAN Support: New library blocks for CAN Transmit and CAN Receive on TI C2000 F2807x and TI C2000 F2837x processors.

  • Hi Brian, Is there a solution available from Mathworks to program a C2000 microcontroller to communicate using Modbus protocol over RS485? I am unable to find anything so far. The microcontroller I am using is TMS320F28335.
  • Hi Rohit,

    The SCI Transmit and Receive blocks can be used for RS485 communication. They are included in the C2000 Support Package. We do not have a Modbus specific implementation, but you can build your own on top of the SCI blocks using standard Simulink blocks and Stateflow diagrams.

    More info (login may be required)

    SCI Transmit

    SCI Receive

    Example model

    There are a good number of configuration details within the Configuration Parameters - here's a quick screenshot:

    Good luck with your project!


  • Hi Chris,

    I am using MATLAB R2015A. I downloaded the support package for C2000 Piccolo MCU but in Simulink I don't have the block for F2807x. Why is it so? Am I missing anything.

  • Hi Prakash,

    The support for F2807x begins with Release R2015b. So you wont see the block library in R2015a. Please update to R2015b (or newer release) and you will gain access to this block library.

    I should also note - we continue to add more blocks and features for C2000 (especially F2807x, F2837xS, and F2837xD libraries in every new release.  There are a number of features that will be added on R2016b in Autumn and R2017a next Spring.



  • Thanks for the info Brian.
  • Hi,

    I am trying to generate a simple code with 2016a and CCS6.

    But I got this error (shown below) in the Matlab command window when I hit the build button in Simulink.

    Could you help me figure it out? 

    By the way, in previous versions (2012 and older), source, library, and header file addresses were entered in Target Preference. In R2016a, I didn't see them. Obviously Target Preference is no more provided. Then, should we enter these source, library, and header files in Custom Code field of Code Generation part in the Model Configuration Parameters. 



    Undefined variable "Stateflow" or class "Stateflow.SLUtils.isChildOfStateflowBlock".

    Error in slmsgviewer/ProcessObjects

    Error in slmsgviewer/pushMessageRecord

    Error in slmsgviewer.processRecord

    Error in slsfnagctlr

    Error in slsfnagctlr

    Error in slsfnagctlr

    Error in slsfnagctlr

    Error in coder.internal.simulinkcodermenus

  • Hi,

    I'm running R2016a, and have never seen this error. Contact MathWorks Technical Support for immediate assistance.

    Most of the target specific info you enter is in the Simulink Configuration Parameters. Click the Gear icon in Simulink to open that, and look in the Hardware Implementation and Code Generation sections - this is where you specify the HW and toolchain (such as CCS).  Also look in the Code Generation -> Templates - this is where you can configure Source file and Header file templates. See R2016a screenshots below.



  • Hi,

    I need to know if MATLAB r2016a is compatible with Code Composer Studio 6.1.3, with C2000 Code Generation Tools 15.12.2.LTS and Control Suite 3.3.9 and SYS/BIOS The main issue I am seeing with the Code Generation tools is that during 'checkEnvSetup', MATLAB recognizes it as 5.12.2 instead of 15.12.2. Will that be a cause of problem in programming the controller? Please reply.
  • Hi Rohit,

    I checked with our development team.  We have not yet tested version 15.12.2 LTS.

    • If you are using ert.tlc and selected the correct version of tools during support package configuration, everything should work fine.
    • If you are using idelink_ert.tlc (which we don't advise - old technology/workflow), it should work fine even though checkEnvSetup is not detecting version properly.

    For the most part you only need to checkEnvSetup for the older idelink_ert.tlc workflow.  We are working to streamline/clarify this for future releases, because it is a bit confusing.

    Helpful hint: To go back and reconfigure, type targetupdater at the command line - this command skips the download and install steps and goes directly to the configuration steps.

  • Thanks Brian. I was able to generate working .out file using following combination of TI software installed:

    Code Composer Studio: 6.1.3
    C2000 Code Generation Tools: 5.12.2.LTS
    ControlSuite: 3.3.9
  • Hi, I have to include the Modbus protocol in the CPU program for F28335. I am generating the code using the C2000 support package for embedded coder so far. I don't quite understand what would be the structure of implementing Modbus RTU over Serial interface and I would like to understand that. Here is what I have gathered from my reading so far:

    1. Each Modbus message has following parts:

     (a) Address field (b) Data field (c) Error check field

    2. The master gives the following message:

     (a) Address of slave addressed (b) Function (c) Error check

    3. A slave checks if the address in current message is belonging to it. If yes, it gives a response with following structure:

     (a) Slave's own address (b) Response to requested function (c) Error check field

    What I fail to understand is how does the transmitted data appear and stored or processed. I have the following structure (not sure if it is correct or sensible):

    1. The data is taken from the SCI receive block after interrupt: I am confused whether the entire MODBUS message is received in one go, or the interrupt occurs after each byte of conversion? Also, how to we detect if the byte obtained is start bit, address or function or error check or stop bit?

    2. The data from step 1 is used in a state machine. If the data is an address, it is first compared to slave address. IF the byte next received is a valid MODBUS function code, an appropriate response is prepared and sent out through the SCI transmit block.

    Can someone help me?

  • Hi Rohit,

     I personally do not have experience with MODBUS, so I cant help you in a significant way other then provide small suggestions.

    Basically what I am told is that you can configure the Serial receive block to get an interrupt after receiving 1-16 bytes based on your requirement. The F28335 processor has 16 bytes serial FIFO. To detect the start, address and data, you have to implement the logic after receiving the data.

    Here is the block help:

    For additional help, please contact MathWorks Technical Support


  • Brian,

    One of our customers is interested in this.
    Does Embedded Coder for F2807x/F2837xS/F2837xD supports generating CLA codes?
    Does it advise how to partition in between C28x/CLA or optmize the code for two cores if both C28x/CLA are used on F2837xS?
    For F2837xD, which has 2xC28x/2xCLA, does it advise how to partition in between C28x/CLA or optmize the code for those four cores?

    Wayne Huang

  • Hi Wayne,

    CLA for the F2837xS/D & F2807x isn't supported, yet. We are actively working on it and I am hopeful it will make the R2016b Release this Autumn. The feature will not provide advice on partitioning - just the ability to do so.  If will operate similar to the CLA support we have for the other parts.

    Using CLA documentation (login may be required)

    CLA Example (login may be required)

    The ability to select the core for your model/algorithm on the F2837xD is already available, you need to select CPU1 or CPU2 in the dropdown.



  • Hi Brian,

    How to program the CPUs (I mean divide the tasks between CPUs) for F28377D using matlab embedded coder, also programming the CLAs? No examples shows the work with this processor.

  • Hi,

    1) We don't yet have CLA support for the F28377D. We're actively working on it, and I hope it will be released soon.

    2) You select CPU1 / CPU2 in Model Configuration Parameters -> Hardware Implementation.  Screenshot below.



  • Hi,

    Thanks for your reply,

    Actually, I knew how to select the processor during debugging. My equation is how to divide the tasks between the processors  in the same simulink window. Assume you have x+y/z+v and you would like to do x+y in cup1 and the result z+v in cup2 and the final results are used in cpu1 to complete the / operation.


  • Hi M_SRM,

    The best and easiest way to program both CPU's on the F2837xD is to use a 2 model approach: Model 1 -> CPU1, and Model 2 -> CPU2.

    I haven't personally done this, as my applications don't merit /require using the second core. I think the most common use case would be using the first core for foreground control loops and calculations, and the second core for background loops and communication.

    We at MathWorks are actively working on improved techniques and tools to deploy to multi-core embedded systems, but they are not yet available to customers.

  • Hi Brian,
    I would like you to take a look in my issue.

    I'm working with TMS320F28035, CCSv5, MATLAB R2015a, and a pms motor.

    I loaded this existing project: HVPM_Sensorless (from ControlSUITE) in CCSv5, wich fits very well to my project. Here in code composer I'm allowed to modify golbal variables like SpeedRef and VqTesting in real time debuggin.

    But, for project reasons, I have to control motor speed, motor direction and torque via MATLAB.

    All these variables can be controlled in Code Composer in the Debug session, but I would like to modify SpeedRef and Torque via MATLAB, in order to achieve project purpouse. If any one know how to modify this variables in MATLAB in real time I'll appreciate to let me know.


  • Hi Caleb,

    If you use a Simulink model, Embedded Coder, and our Support package for C2000 MCU's, you can use a feature called External Mode to interactively tune parameters and log data from Simulink on a C2000 MCU.

    Here is a documentation link (login may be required):

    The key here is that this requires a Simulink model. So you'd need to implement that CCS example Simulink to use the MathWorks workflow and leverage External Mode.  When MathWorks auto generates the code with for the MCU with this workflow, we add the External mode feature into the code which allows for the parameter tuning and signal logging - it isn't available otherwise.

    You might be able to communicate to MATLAB manually via a serial link, but I don't think that will allow you to do parameter tuning - just log the data.



  • Thanks a lot Brian,

    I'll follow these steps and try to design the simulink model for HVPM Sensorless.
    I really appreciate your answer and time.

    Regards. -Caleb
  • MathWorks Release R2016b is now available to customers, and includes new library blocks for C2000 processors:

    1) eCAP Support: New library block for capturing input pin transitions or configuring auxiliary pulse width modulator on TI C2000 F2807x and TI C2000 F2837x processors.

    2) eQEP Support: New library block for interfacing with a linear or rotary incremental encode on TI C2000 F2807x and TI C2000 F2837x processors.

    3) CLA Trigger Support: New library block allows you run code on Control Law Accelerator (CLA) co-processor available on F2803x, F2806x, F2837xS, F2837xD, and F2807x processors.

    4) DAC Support: New library block for converting digital data to analog signal on TI C2000 F2807x and TI C2000 F2837x processors.


    We added examples which will work with the F28377S LaunchPad.  They are listed along with the examples for existing devices (such as F28069, for example)

    We enhanced external mode to use serial flow control, so you can now log ~20 signals at 1kHz, or 1 signal @ ~5kHz on a C2000.


    Here's a screengrab of the updated F2837xS block library:

    Remember, the support is a free download, but does require Embedded Coder from MathWorks.

  • Hi Brian,
    I notice that the embedded coder library for F28377D is much improved. However, I have problem with the external mode communication, when I run the external mode I got this error:

    *** Starting debug session...
    SEVERE: IcePick_C_0: Error connecting to the target: (Error -151 @ 0x0) One of the FTDI driver functions used during the connect returned bad status or an error. The cause may be one or more of: no XDS100 is plugged in, invalid XDS100 serial number, blank XDS100 EEPROM, missing FTDI drivers, faulty USB cable. Use the xds100serial command-line utility in the 'common/uscif' folder to verify the XDS100 can be located. (Emulation package

    SEVERE: emulation failure occurred
    SEVERE: Error connecting to the target: emulation failure occurred
    *** Cannot create a valid debug session for Board/CPU=*/C28xx_CPU1.
    Make sure this matches only one board and one CPU.

    Any help with this is appreciated?

    I think Matlab is used SCI-A as a default serial port for sending and receiving the data from and to Matlab; unfortunately, I don't have SCI-A on the board I only have SCI-B. Is there any way to change the default to use B for communicating with the external mode in Matlab. I asked Matlab about this for a long time but I didn't hear from them anything.

    Many Thanks
  • Hi,

    I'll check with MathWorks development on this. Are you using the F28377D on a TI product, or is the chip socketed on your own board?

  • It my own board with a chip socketed.

  • Hi,

    Here is some feedback from my development team:

    1) From the error log, it looks like downloading to the hardware board is failing. Please ensure that you can connect to the board using CCS.


    If you are able to connect to the hardware using CCS, then use the same ccxml configuration file in your Simulink model also. You can change is from Model Configuration Parameter -> Hardware Implementation -> Target Hardware Resources -> CCS hardware configuration file.


    2) SCI-A is used by default for external mode by default. You can modify the shipping source file (SUPPORT_PACKAGE_INSTALLATION_FOLDER\toolbox\target\supportpackages\tic2000\src\rtiostream_serial_c28x_ext.c) to configure the SCI-B for external mode.




  • Dear Brian,

    Thank you very much for your help and concern indeed,

    I did the suggested solutions in the previous post; however, I faced other error this time (shown below); any suggestion is really appreciated.

    Many Thanks


    >> Compilation failure 
    gmake: *** [rtiostream_serial_c28x_ext.obj] Error 1 
    C:\Users\Documents\MATLAB\ex_test_2_ert_rtw>echo The make command returned an error of 2  
    The make command returned an error of 2 
    'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command, 
    operable program or batch file.
    ### Creating HTML report file ex_test_2_codegen_rpt.html
    ### Build procedure for model: 'ex_test_2' aborted due to an error.
    Error(s) encountered while building "ex_test_2":
    ### Failed to generate all binary outputs.
  • Hi M_SRM,

    Clearly a build error - but not enough info for me to help diagnose it.  Probably fastest way to get help is for you to contact MathWokrs Technical Support.



  • I recommend you to try to change the toolchain to the new version (Texas Instruments C2000 Code Generation Tools v6.x.x) in the embedded coder configuration. Then, it should work.
  • Dear All,

    You can follow my YouTube Channel for Video Demonstrations on using Simulink with C2000 devices & Booster Packs :



  • We just posted YouTube Live video and example model of a new DC-DC Buck demo using F28377S LaunchPad an DPS BoosterPack.

    Link to YouTube Live session:

    Link to example model:

    If you are interested in Digital Power with C2000 and MathWorks tools, check it out.


  • Brian,

    Finally I programmed my F28379 processor through Simulink. Now I'm able to transmit messages over CAN but I can't read it with Vector CANalyzer or other CAN transceivers. When I monitored the signal with oscilloscope, I saw this weird waveform:

    There should be something wrong with my transmission configuration. CAN communication is supposed to be a differential comm system but as you can see both high and low waveform are identical. 

    Is there any wrong setting I'm using? I'm confused because I didn't find anything in Simulink.



  • Hi Kash,

    I'm not sure why you see these results.

    Did you double check that your have your 120 ohm termination resistors? I suspect you do, but still worth checking - just in case.

    You can contact MathWorks Technical Support for additional assistance.



  • Brian,

    Yeah, I just double checked.

    It's very odd, I've never seen CAN waveform like this. I'm still thinking there should be something wrong in my settings, check this out please:

  • Refer the video for proper CAN block configuration:
  • It appears you are scoping CANTX & CANRX on the MCU side (i.e. "before" the CAN transceiver), not CAN_H and CAN_L of the CAN-bus "after" the CAN transceiver. If you capture the ACKnowledge phase also on the scope you should see a "high" on CANTX and "low" on CANRX. 

  • Hareesh,

    I have a controlCARD and I'm scoping CANTX and CANRX directly from the controlCARD pins. I mean for example GPIO4 and GPIO5. What do you mean by scoping the CAN_H and CAN_L and also the acknowledge? What pins do I need to monitor?

  • Hareesh,

    I think I found out what the issue is. I'm using TMDSDOCK28379D prototype board and there is no CAN transceiver on it while on LAUNCHXLF28379D boards, there is a SN65HVD234DR CAN transceiver as below. That's why I can't see the differential signal waveform.

  • Gautam,

    Thanks for your message.

    I watched your movie, it's actually helpful but I think I found out the problem. I'm using TMDSDOCK28379D prototype board and there is no CAN transceiver on it while on LAUNCHXLF28379D boards (the one that you're using) there is a SN65HVD234DR CAN transceiver as below. That's why I can't see the differential signal waveform so I can't use CANmate or other devices to read CAN messages. May be I need to switch LAUNCHXL boards. 

  • Aaahhhh... Indeed that's the issue!
  • MathWorks Release R2017a is now available for download.  We've made some enhancements to our C2000 Support, which is a free download but requires our Embedded Coder product.

    • Generate projects for CCS versions 5 and 6with Embedded Coder Target for TI C2000
      • When you build Simulink models for TI C2000 targets with CCS v5 or v6 toolchains, the Code Composer Studio project is also generated. You can use this project for debugging the generated code.
    • SPI and I2C blocks added to TI C2000 support package



    SPI Receive

    Receive data via serial peripheral interface (SPI) on target.

    SPI Transmit

    Transmit data via serial peripheral interface (SPI) to host.

    I2C Receive

    Configure inter-integrated circuit (I2C) module to receive data from I2C bus.

    I2C Transmit

    Configure inter-integrated circuit (I2C) module to transmit data to I2C bus.

    • CCS v3.3 IDE automation support for TI C2000 has been removed
      • The support for TI C2000 with idelink_ert.tlc as system target file has been removed. You can still use the TI C2000 support by using the ert.tlc as the system target file.

    • Real-time multitasking profilingfor TI C2000
      • You can use real-time execution profiling to verify whether generated code meets the real-time performance requirements.


    The project creation might be particularly helpful if you don't already have an existing CCS project - easing the the transition from the MathWorks environment to the CCS environment for C2000 projects.

    Also, if you are doing power systems, don't forget we posted a new example for a DC-DC Buck with F28377S LaunchPad. There is an associated YouTube video which explains the demo.



  • I love the first and last features, they will be really useful.
  • Thanks for the update Brian! Really very helpful.
  • MathWorks video: F28069M TI processor for AC Motor control

    A MathWorks Senior Application Engineer has been doing a series of videos on Mechatronics.  He just posted a new video that shows targeting of F28069M TI processor for AC Motor control. This is part of the YouTube series, Mechatronics with MATLAB & Simulink.

    Here’s a link to the new video:

    A lot of details in here on how to go from simulation model to HW, and showing the results on O-scope. Take a view, should be interesting for people who are working thru implementation details from MathWorks tools to C2000 MCU's.



  • WOW! All three of the added features were ones I was hoping for. I may just have to download 2017a!

    Don Johnson,