Hi, I am using c51 keil compiler with cygnal chip c8051C020. I find problem in initilise static variable. exp. main() { static unsigned char i =0 ; i++; } when i write this type of code & simulate it ,i find that i is not initilise to 0. Note:this is just example code & not the actual program i work. If any specify me the reasion it will help me lot. Regards, Pandurang S.
Hi Erik, Thanks once again. The example you given quite same as the config file generated by cofig2. But still i am not clear how to init static variable (may be to 0 or other than 0 value) that are used in a function,which is call by my main function. What is the relation betn the example u given & library files(init.a51 & startup.a51). Regards, Pandurang S.
Hi Erik,... the example u given I can not comment on an example given by micro. Erik
Hi, Leave the part of example. "But still i am not clear how to init static variable (may be to 0 or other than 0 value) that are used in a function,which is call by my main function." Regards, Pandurang S.
Hi, In my code when i have define the static variable in the internal memory with keyword idata, then the varable is initilise to proper value but when it come to xdata during 2nd trial(for testing i again define it to extermnal memory) it is not initilise to the value other than 0. Regards, Pandurang S.
then the varable is initilise to proper value but when it come to xdata during 2nd trial(for testing i again define it to extermnal memory) it is not initilise to the value other than 0. This is getting ridiculous HOW OFTENM DO I HAVE TO REPEAT? If the external memory is not configured at the beginning of (a private copy of)startup.a51 variables in external memory will NOT be initialized. Erik
"This is getting ridiculous HOW OFTENM DO I HAVE TO REPEAT? If the external memory is not configured at the beginning of (a private copy of)startup.a51 variables in external memory will NOT be initialized." But we have already established that the derivative in question defaults to using internal XDATA, so that does not appear to be the problem.
If the external memory is configured before startup clear and ljmp ?C_START it will not be initialized. My experience is that if it is configured before startup clear and ljmp ?C_START it will be initialized. Also that would be the way the Keil software should work. Thus I see no other place that would affect the issue. Who knows (I refer to f12x for my knowledge) what SFR if the f020 could have a hidden effect re memory access. Erik
"If the external memory is configured before startup clear and ljmp ?C_START it will not be initialized." "My experience is that if it is configured before startup clear and ljmp ?C_START it will be initialized." Those statements appear to be in complete contradiction. What are you trying to say?