SPRU514Z July 2001 – October 2023 SM320F28335-EP
If your loader does not preinitialize variables, you can use the linker to preinitialize the variables to 0 in the object file. For example, in the linker command file, use a fill value of 0 in the .ebss section:
SECTIONS
{
...
.ebss: {} = 0x00;
...
}
Because the linker writes a complete load image of the zeroed .ebss section into the output COFF file, this method can have the unwanted effect of significantly increasing the size of the output file (but not the program).
If you burn your application into ROM, you should explicitly initialize variables that require initialization. The preceding method initializes .ebss to 0 only at load time, not at system reset or power up. To make these variables 0 at run time, explicitly define them in your code.
For more information about linker command files and the SECTIONS directive, see the linker description information in the TMS320C28x Assembly Language Tools User's Guide.