Skip to main content

IAR Embedded Workbench for RX 5.20

System initialization

In this section:

It is likely that you need to adapt the system initialization. For example, your application might need to initialize memory-mapped special function registers (SFRs), or omit the default initialization of data sections performed by the system startup code.

You can do this by implementing your own version of the routine __low_level_init, which is called from the cstartup.s file before the data sections are initialized. Modifying the cstartup.s file directly should be avoided.

The code for handling system startup is located in the source files cstartup.s and low_level_init.c, located in the rx\src\lib directory.

Note that normally, you do not need to customize cexit.s.

Note

Regardless of whether you implement your own version of __low_level_init or the file cstartup.s, you do not have to rebuild the library.

Customizing __low_level_init

The value returned by __low_level_init determines whether or not data sections should be initialized by the system startup code. If the function returns 0, the data sections will not be initialized.

The code calling __low_level_init at startup is only included if a module containing a __low_level_init definition is included when linking.

Note

The file intrinsics.h must be included by low_level_init.c to assure correct behavior of the __low_level_init routine.

Modifying the cstartup file

As noted earlier, you should not modify the cstartup.s file if implementing your own version of __low_level_init is enough for your needs. However, if you do need to modify the cstartup.s file, we recommend that you follow the general procedure for creating a modified copy of the file and adding it to your project, see Overriding library modules.

Note

You must make sure that the linker uses the start label used in your version of cstartup.s. For information about how to change the start label used by the linker, see ‑‑entry.