MATLAB Answers


Is there an example Freescale S12X target for Real-Time Workshop and Simulink using the Cosmic Compiler?

I am interested in generating code using Real-Time Workshop that can be embedded on the Freescale S12X processor. In particular, I want to be able to generate device driver code and integrate that to my model. I would also like to run processor-in-the-loop (PIL) testing to verify the numerical equivalence of results obtained from running my model as code on the embedded processor using Code Generation Verification (CGV).

1 Answer

Answer by MathWorks Support Team on 7 May 2018
 Accepted Answer

Attached is a demo kit (compatible with R2009a - R2010a) containing example models, code generation files, and an instruction guide on generating code for the Freescale S12X processor using the Cosmic compiler. In addition, you will also need to download third-party files from Cosmic Software at the following URL:
The instruction guide explains the steps needed to run the demo that shows how to generate code for the processor and run processor-in-the-loop testing. It also shows how to verify the numerical equivalence of the results from normal simulation and PIL simulation using Code Generation Verification (CGV). A video showing an overview of the demo kit can be found at the following link:
The intent of the demo kit is to provide a working example that end users can use as a base to create their own target solution using the Real-Time Workshop and its Customizing Targets guide:
The intent is not to provide a full featured and maintained Embedded Target product as may be provided by MathWorks or third-party products listed in supported hardware page:
However, if you have questions on this solution, send an e-mail to
If you are looking for more complete solution for the S12x processor, our partner SimuQuest offers the QuantiPhi product that provides Device Driver Blocksets for the S12x processor. You can find more information at the following page:
Note: This solution uses several third-party products to compile and download the C code to the S12X. Evaluation versions were used but the demo kit also supports full versions of these products. The installation guide identifies the specific releases versions used and provides information with links on how to obtain these products, but these details may change. Contact the third-party vendors with questions or information on how to obtain the third-party products.

  1 Comment

Sir, I have download and try your demo, however there is some problem with s12x_pwm.tlc. Matlab will report error whenever call SLibCodeGenForSim(). And I don't know where I can find the defination of this function.

Sign in to comment.