The Code Mappings pane is a useful tool for adjusting the storage class of Simulink signals. If it isn't visible, it can be accessed by selecting Code Interface > Individual Element Code Mappings from the C CODE tab in Simulink Coder.
To make specific block outputs global in the generated code, follow these steps:
1. Go to the Signals/States tab in the Code Mappings pane.
2. Select the output signal whose storage class needs modification and click the Add selected signals to code mappings,
icon. 3. Change the storage class of the signal to ExportedGlobal.
4. Click the
icon on the right and edit the identifier name to the desired value, which will be the signal's name in the generated code. After these steps, click Build to generate the code. The global signal can be viewed in the generated code using the report.
For more information on Code Mappings, please refer to this page: