Generate and download code to run in RAM on ARM Cortex M3, Linux, and C2000 targets

During the automatic code generation process, Embed generates a C file from your diagram, then links it with the necessary object files to create an executable file (OUT) to run on the target.

Note that when downloading the code to AMD64 or Raspberry Pi, Embed uses the following ports:

      TCP ports 50009 and 57893

      UDP ports 50002, 50003, and 57892

Additionally, when targeting a Raspberry Pi device, you can ensure the executable runs on all Raspberry Pi devices by selecting the slowest Raspberry Pi devices, either 1APlus or 1BPlus.

For the ARM Cortex M3 and C2000 devices, you can alternatively generate code to run in FLASH.

1.    Open the diagram.

2.    If you are generating code for a subsystem, select the compound block that contains the subsystem.

3.    The first time you generate code for the subsystem, choose Tools > Code Gen. For subsequent code generation, press SHIFT+right-click and click Compile to automatically generate code based on the selections in the Code Generation dialog.

A screenshot of a computer

Description automatically generated

4.    Do the following:

      Under Result File, check that the file name displayed is named currently-open-diagram-name.C.

      Under Result Dir, check that the directory is Embed-install-directory\cg. If it is not, click … to update the directory.

      Under Target, choose the platform you are targeting. By default, Embed uses the last target you specified for the diagram.

      Under Subtarget, check that the selected CPU is correct. If it is incorrect, click Quit and update the Target Config block in the diagram. After you save the diagram and click on Tools > Code Gen, the subtarget will reflect your change.

5.    Choose the remaining code generation parameters.

6.    Click Compile. The following actions are performed:

      The integration algorithm is set to Runge Kutta 4th order if it was previously set to an algorithm more complex than Runge Kutta 4th order.

      A C file is generated. Blocks are translated either directly into one or more C operations or into one or more calls to the Embed C support library. A small set of blocks are unsupported in Embed and are translated into function calls that produce EMPTY returns.

      The C compiler included with the Embed hardware kit is invoked to compile and link the C file, support libraries, and header files to create an OUT file, which is stored in the same location as the C file.

      A Command window is opened in which to view the code generation, compilation, and linking phases.

7.    Click any key to exit the Command window.

8.    Click Download in the Code Generation dialog to start the process of downloading the OUT file to your embedded target. The following dialog appears.

A screenshot of a computer error

Description automatically generated

9.    Under Target Execution File, specify the OUT file to be downloaded, if it is not already set to the file path.

10.  Click Coff Info if you want to access information about the sizes of the various linker segments, including data, text, and initialization.

11.  Click Download to download the code to the target RAM.