Hi. I am using uVersion2 IDE. Here after reset, MPU will execute code from reset vector located in Startup.A51 file and after some initialization, it will jump to label named as ?C_START which is defined in Init.A51, where it does some other initialization. If we dont include the Init.A51 in project, then will it automatically include for project ? If we dont want to use this Init.A51 file and instead of jumping to ?C_START from Startup.A51, we modify this to jump to Main direclt then will it create any proble ? Thanks.
The C standard specifies that any global variable which does not have an initializer is initialized to zero. There are several loops, one for each memory space (idata, pdata, xdata, etc), in the STARTUP.A51 file that zero out all of the memory. This code implements the requirement of the C spec that uninitialized variables are zero. The compiler takes all of the explicit static initializers and puts them into the code (ROM) area. INIT.A51 copies this region of initialized data to RAM. INIT.A51 implements the C standard feature for initializing global variables. If you omit INIT.A51 from your build, then any program which relies on static initializers will not work correctly. You will have to write code that explicitly initiazes variables the way you want them. For example, this code will fail miserably if you omit INIT.A51
U8 lookup[8] = { 7, 6, 5, 4, 3, 2, 1, 0 }; void main (void) { ... translated = lookup[input]; ... }
U8 lookup[8]; ... void LookupInit (void) { U8 data i; for (i = 0; i < 8; ++i) { lookup[i] = 7 - i; } } // LookupInit ... void main (void) { LookupInit(); translated = lookup[input]; // works only after call to LookupInit(); }