I am facing an issue with initialization. I created a project with uVision3. I modified standard start up file STARTUP.A51 for my application as below:
?C_C51STARTUP SEGMENT CODE ?STACK SEGMENT IDATA RSEG ?STACK DS 1 EXTRN CODE (my_main) ;EXTRN CODE (?C_START) ;--- commented ?C_START ;.........Standard Code....... IF PBPSTACK <> 0 EXTRN DATA (?C_PBP) MOV ?C_PBP,#LOW PBPSTACKTOP ENDIF MOV SP,#?STACK-1 ;LJMP ?C_START ;--- commented jump to ?C_START LJMP my_main
NOTE: my_main is a starting function defined in my project.
I am including this modified file in my project. Also i am not including INIT.A51. With this i am facing an issue in my code. Whenever i initialized global data, program wont take it. For example, if i initialized below global variable:
unsigned char counter = 5;
When in code i checked counter value, it is always 0x00. I think this is problem with not calling ?C_START which is defined in INIT.A51. Due to this, all global initialisation is not happening.
Is this correct ? Is there any way to avoid this issue (apart from including INIT.A51)? Can anyone tell me which part of the INIT.A51 file i can copy to STARTUP.A51 before below code
;LJMP ?C_START ;--- commented jump to ?C_START LJMP my_main
so that i cant have this issue ?
Thanks in advance !!
To Erik, I tried to init global variable as
char blah = 5;
However i found that it is initialized with 0 only, not with 5.
To others, It was a mistake done earlier by removing init.a51, trying to fix it.
Thanks for reponses.
So why didn't you just replace the INIT.A51??
As already noted, the purpose of INIT.A51 is documented here: http://www.keil.com/support/man/docs/c51/c51_ap_customfiles.htm
char blah = 5; However i found that it is initialized with 0 only, not with 5.
of course, when you muck with init you will get such. Do not "try to fix it" just start over.
Erik
Sure Erik, Will do that.
Thanks...