2004-03-03 07:22 AM
2004-02-12 08:06 AM
I work on ST72F521. I use the Cosmic compiler.
I found a very trange behavior of the compilation with a Cosmic. When I declare an initialized pointer out of routine, for Ex: const char nv_database[]={1,........,5,7}; char *ptr=nv_database; main() { while(1){ ,,,,,,, (about 30K) } } when I debug it with indArt It runs and crash imidiatly! but when I do: char *ptr; main() { *ptr=nv_database; while(1){ ,,,,,,, (about 30K) } } It works! I've also found a problem with a static initialize variable in subroutines. for Ex: void CTRL_autoarm_F(void) { static UINT8 goToARM=FALSE; UINT8 arm_hour,clock_hour; int arm_time,clock_time; ,,,,,,,,,, ,,,, } crash at the start of runnig code ! but when I do: void CTRL_autoarm_F(void) { //static UINT8 goToARM=FALSE; UINT8 arm_hour,clock_hour; int arm_time,clock_time; ,,,,,,,,,, ,,,, } It works and run! can some explain what is wrong with compiler or ST7 ? tanks atz2004-02-12 08:11 AM
2004-02-12 09:39 AM
Check the initialisation routine used in the .lkf file used by your linker.
You need to use crtsi or crtsx instead of crts for automatic initialisation. Eg C:\COSMIC\cxST7\LIB\CRTSi.ST7 works for me. BM2004-02-14 06:29 PM
I link the software with the crtsi.o and I still get this problem.
2004-02-25 08:42 PM
Hi Datz,
which memory model are you using? If you are using one that put globals outside of page 0 by default (modms, modml and modsl), then you need to use the crtsx startup file. If you use crtsi, the startup will try to initialize variables at an address where there's actually something else (example: write in 02 for a variable that is in 0x102) thus resulting in a probable crash. If you initialize the variables ''by hand'', the startup won't do anything and the crash will go away. Hope this helps. Regards Luca2004-03-03 07:22 AM
hi luca,
As you said, my problem has been solved after I used crtsx. Thank you for your help! atz