How can I add my own code to be inserted as part of the system startup?

To add your own code:

  1. In the CPU component properties, click the Build options tab.
  2. Select User code before PE initialization from the User initialization group.
    Figure 1. User Code before PE initialization

    User Code before PE initialization

  3. Click (...) button from the Value column.

    The String list editor dialog box appears.

  4. In the String list editor dialog box, specify the code you want to be inserted as part of the system startup.
  5. Click OK.
  6. To add the user defined header file, select User data declarations from the User Initialization group.
    Figure 2. User data declarations

    User Data Declarations

  7. Click (...) button from the Value column.

    The String list editor dialog box appears.

  8. In the String list editor dialog box, specify the header file to be inserted as part of the system startup.
  9. Click OK.

The code snippets get added to the __init_hardware() function which is called from the bootloader startup code:

Figure 3. Custom Startup Code with Bootloader Code Inserted

Custom Startup Code with Bootloader Code Inserted