cancel
Showing results for 
Search instead for 
Did you mean: 

Cosmic compiler - Run time error

seecure
Associate II
Posted on March 03, 2004 at 16:22

Cosmic compiler - Run time error

6 REPLIES 6
seecure
Associate II
Posted on February 12, 2004 at 17:06

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

atz
seecure
Associate II
Posted on February 12, 2004 at 17:11

I'd like to fix my mistake ''*ptr=nv_database''

should be:

ptr=nv_database;

peterharris9
Associate II
Posted on February 12, 2004 at 18:39

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.

BM

seecure
Associate II
Posted on February 15, 2004 at 03:29

I link the software with the crtsi.o and I still get this problem.

luca239955_st
Associate III
Posted on February 26, 2004 at 05:42

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

Luca

seecure
Associate II
Posted on March 03, 2004 at 16:22

hi luca,

As you said, my problem has been solved after I used crtsx.

Thank you for your help!

atz