Generate and download code to run in FLASH on Arduino, MSP430, and STM32 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 or ELF) to run on the target. When you generate executable code for an MSP430 or Arduino, the code can only run in FLASH due to the limited amount of RAM on them.

If you want to flash code to a Texas Instruments C2000 or ARM Cortex M3, see Flashing generated code with UniFlash.

1.    Open the diagram.

2.    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.

3.    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 this 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.

4.    Choose the code generation parameters.

5.    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 or ELF file.

      An MS/DOS window is opened in which to view the code generation, compilation and linking phases.

6.    Click any key to exit the MS/DOS window and return to the Code Generation dialog.

7.    Click Download in the Code Gen dialog to start the process of downloading a stand-alone OUT or ELF file to your embedded target. The following dialog appears.

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

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

10.  Click Download to download the code to the target FLASH.