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

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.


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 2019-01-22

141 Replies

  • Hello,

    I am using the F28379D with Simulink and it worked fine so fare (toggling LED, output PWM, reading ADC).
    However I am having some trouble with the CAN functionality.

    I would like to periodically (let's say at 10 Hz and 20 Hz) transmit CAN messages with different ID's.

    However the message with the highest priority simply spams the CAN-bus and no other message is transmitted.

    For my example code I used two timers to generate periodic interrupts.
    Using the hardware interrupt I call two function-call subsystems periodically. (This works fine as I employ two blinking LEDs to verify the periodic calls to the subsystems.)
    Each of the subsystems should transmit a CAN message with a different ID.
    But only the message with the higher ID/priority is transmitted and this at a much higher frequency than the LED blinking.

    As far as I understand the problem, the CAN message is not posted, transmitted once and then the transmission is stopped. But the message simply remains in the message box and is therefore posted every-time the CAN-bus is free.

    Enabling blocking mode did not change the behavior.

    Do I need to somehow use the "Interrupt after transmission" to change the ID of the message to a lower priority in order to allow other messages to pass. I doubt that this is the intended behavior of the eCAN transmit block.

    Best Regards,
  • In reply to Bob Hoffmann:


                A message in a mailbox is transmitted only when the TRS bit of that mailbox is set. I presume your timer ISR sets the TRS bit. Therefore you see that message over and over again on the bus. Since this timer interrupt occurs at a more frequent rate than the other timer, messages from this MSGID "monopolize" the bus and does not let the other message get through. Perhaps you could have a software flag called "New_data". You set this flag when you have new data to transmit and clear this flag once the transmission is done. Your ISR should check this flag and initiate a transmit only when this  flag is 1. To summarize, there is nothing abnormal with the behavior of the CAN module. The device is doing exactly what you are asking it to do.



    If the issue is resolved, please close the forum post.

  • In reply to Hareesh J:

    Dear Hareesh,
    thank you for your response. If I would be writing C-Code I would agree with you.
    However I am planning on reducing the need of manually written C-Code to the absolute minimum in my current project and instead rely on Simulink code only.
    I am using the Matlab/Simulink target support package of the C2000. And in there is the "eCan Transmit" block, which I use to transmit the CAN messages. The current behavior of the CAN module is probably due to the way this transmit block is implemented, (which I do not intend to modify).

    Would it be possible to propose a solution relying only on the currently implemented library blocks?

    Best regards
  • In reply to Bob Hoffmann:


    This is the natural behavior of CAN transceivers, they keep sending the last message stored in their buffer unless a new message comes in. The MCU laso sends the higher priority message first but if you set up your Simulink model correctly, I don't think you get the issue. Here is how I constructed my model in Simulink:

    Inside the subsystem:

    So as you can see I'm toggling two LEDs with 1 and 2 sec delay interval to make sure my subsystem is getting triggered, and transmitting two different messages over CAN with two different ID and Mailbox priorities as below:

    1. Send "1" and increment it by 1 every 2 sec. MSGID: "111000111" (1C7) and Mailbox number: 2

    2. Send "1" and increment it by 1 every 1 sec. MSGID: "111100111" (1E7) and Mailbox number: 3

    Here is the result on CANalyzer:

    As it's clear, both messages are being transmitted and their value is getting incremented. 

    Hope it helps you to find the issue in your model,


    If my post answers your question, please click on "Verified answer".



  • In reply to Khashayar olia:


    The default blocks in the C2000 library don't transmit continually, at least not in my implementation.

    I suspect you are missing the ack bit, which can cause the transmitting node to continually attempt to resend the frame.



    Finally, an acknowledgement (ACK) error occurs when SLLA109 4 A System Evaluation of CAN Transceivers the transmitter does not monitor a dominant bit in the ACK slot to signify that the message has been received properly by another node.


    In a two-node experiment, if one node enters the bus-off state, the bus would become silent, or the other node would continue to retransmit until the reception of a proper ACK bit. Either case represents experimental conditions, causing a heavily disturbed bus that is not recommended for use in a final application.


    What tool are you using to monitor the bus? If you are using a scope it will (in my experience) not send an ack bit. I think most monitor tools (CANalyzer etc.) will send the ack bit by default. Do you have another node on the bus? If not you will be missing the ack bit and in my past experience this can cause the transmitting node to continually attempt re-transmit. I saw this when using a scope to monitor a CAN bus and I needed to add a second node to stop the re-transmit.

    The F28379D has two CAN busses. You could try connecting them together so the second one could be the "receiving" node and send the ack bit. I assume you are using a CAN transciever(s) and not simply looking at the Tx & Rx from the micro.

    Good luck,


  • In reply to Donald Johnson:

    Dear Don,

    I am indeed using a scope (with CAN decoding functionality) to monitor the bus, but I am pretty sure that this one does not send any ack bit.
    And as I was testing it as a single node setup, the described behavior of "the transmitting node to continually attempt to resend the frame" sounds like a plausible explanation.

    I am using the F28379D Launchpad development kit, which has only a single CAN transceiver on it. But I will simply connect two of the kits in order to test the hypothesis. Otherwise I might also find a CANanalyser somewhere in the lab.

    Thank you all for being so responsive!


    Problem solved. With two nodes on the CAN bus the problem no longer appears. So I was indeed missing the ack bit.

    I will be more careful with the correct "electrical" setup of the CAN bus for the final application.

    Thank you for your help.

  • Hi all,

    I have a question about using Mailboxes to transmit and receive CAN messages in Simulink. As far as I know I'm limited with 32 Mailboxes for CAN communication in Simulink. This means I can have up to 32 distinct CAN messages. I'm wondering if there is any way in Simulink to use the same Mailbox for multiple messages so I would be able to have more than 32 messages.

    Based on TI expert, I can use Masking feature in CCS to use the same Mailbox for multiple messages. Can i use Masking feature in Simulink? if so, how do I use it?

    I was thinking of making a library that contains eCAN_TX/eCAN_RX block and call it in my model when I'm ready for transmission.





  • In reply to Khashayar olia:

    Hi Kash,

    I received an example of how to workaround this from my development team, but I cannot attach in E2e (file extension is not allowed). Here are their comments and a screenshot

    In this example we are configuring the mask settings for mailbox – 0 to receive any message with standard identifier less than 256.

    This mask configuration is done in the system initialize block as we don’t have a Simulink block to do the same. Thus with the mask settings, we can receive more than one message per mailbox thus overcoming the restriction of receiving only 32 distinct message.

    DM me your email address and I can send file to you.


    Brian McKay  |  Technical Marketing  |

  • In reply to Brian McKay:


    Trying to add attachment here as .zip.  Ugly URL, so please let me know if it works correctly.



    Brian McKay  |  Technical Marketing  |

  • In reply to Brian McKay:

    Hi Brian,

    Thank you very much for your support.

    That's funny but I solved it yesterday by myself and surprisingly my solution is exactly the same as your development teams :))), take a look at the below model, I toggle between two message every 1 sec:

    I tested several approaches but it seems to be the only way to transmit several message with one Mailbox. I'm glad that my method is already approved by Mathwork development team. :) 





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.