How do I make a copy of a C28x (TI C2000) block with a corrected .tlc file?

3 views (last 30 days)
I'm trying to use the eCAN Receive block in the Embedded Coder Package for TI C2000 Processors.
Looking at the block I noticed that the receive message mask parameter was missing. In the .tlc file in C:\ProgramData\MATLAB\SupportPackages\R2018b\toolbox\target\supportpackages\tic2000\blocks\mex\tlc_c it looks like a copy/paste error and a missing parameter.
tCANMsgObject sRXCANMessage;
unsigned char ucRXMsgData[8]= {0,0,0,0,0,0,0,0};
sRXCANMessage.ui32MsgID = %<messageID>; // CAN message ID
sRXCANMessage.ui32MsgIDMask = 0; // no mask needed for TX
No big deal. I should be able to make a copy of the .tlc file and a new S-function block that points to the corrected .tlc file in my project. This is where I am stuck. I'll explain my thinking, but please point out where I'm wrong as I'm new to this topic.
After reading many posts on custom S-functions, my understanding is that the block actually points to the source file (some .c file) that implements it. That source file is then compiled into a .mexw64 file (some kind of Matlab byte code?) via MinGW. That .mexw64 file is a generic matlab function that can be used to genereate .c code and that .c code can be customized on a per-target/enviornment basis using a .tlc file.
Great, the problem is the source file does not exist, or I cannot find it. The mexw64 file exists here:
and the .tlc file exists here:
but what source was used to create the .mexw64 file?
I don't really understand where to go from here, but I'll ask a couple of succinct qustions to try and move forward:
  1. What source does the C280x eCAN Receive block point to? When I create a custom S-function I have to point it to a valid source (.c, .cpp, etc...) file. When I open the S-function for this eCAN Receive block, that option is grayed out and I can't inspect it.
  2. Is there any way to deconstruct the .mexw64 file to see the source? For this block all of the interesting code seems to be in the .tlc file, but the .mexw64 file is 135 kB, so it's obviouslly doing something.
  3. Is there a way to point the S-function block to the .mexw64 file instead of the source file?

Answers (1)

Mark McBroom
Mark McBroom on 29 Jan 2022
  1. In general MathWorks does not provide C/C++ source code for S-Functions
  2. There is no way to deconstruct the .mexw64 file. The .mexw64 file is compiled C/C++ code in the form of a windows DLL
  3. The s-function block already points to the mexw64 file. The S-Function Name field in your screen shot is the name of the .mexw64 file.
If there is in fact a bug in the TLC file, you can edit and modify this file. You can also use the TLC debugger to set a breakpoint in the TLC file to check the values of other variables and single step through TLC code.
  1 Comment
Jonathan Enz
Jonathan Enz on 31 Jan 2022
Edited: Jonathan Enz on 31 Jan 2022
Well editing the .tlc file doesn't really solve the problem because:
  1. Anyone else building the project would have to have the same exact edit to the .tlc file, and the project would not be able to be built without the same exact change. I'd much rather make a copy of the .tlc file and put it in the project's source control.
  2. The bug is that the message ID mask parameter was left out for the Rx block. This isn't needed in a Tx block and it looks like the code was copied from there. Therefore, the fix is a change to the .tlc file and adding the missing parameter. How would I add that paramter if I can't edit the S-function?

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!