It is important to check that C code generated by Embedded Coder® from Simulink® and Stateflow® complies with MISRA C:2012 coding standards. This workflow illustrates the process of evaluating your generated code for compliance to MISRA C:2012 guidelines.
Design your model in Simulink or Stateflow.
If necessary, modify the model to adhere to the Modeling Guidelines for MISRA C:2012 Compliance.
After the MISRA C:2012 checks pass, generate code by using Embedded Coder.
To avoid possible name clashes, multiple functions definitions, and multiple data definitions, use one of these code generation approaches:
Single model: Generate code from a single model, including submodels, by using Model blocks.
Multiple models: Generate code from multiple models, including:
A shared utility folder to synchronize functions
Data ownership to control data definitions
Hand integration to manage code generated from various models
Execute the Polyspace® Bug Finder™ MISRA C:2012 Checker (Polyspace Bug Finder).
For more information about running a Polyspace analysis on your generated code, including analysis options and results, see:
Justify violations to the MISRA C:2012 coding standards using Polyspace annotations (Polyspace Bug Finder).