random number generation CW 5.7 MC9S08RE16

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

random number generation CW 5.7 MC9S08RE16

2,769 Views
stevec
Contributor III
I wish to generate a random number using the rand() function.as in

number = rand();

but I get a warning "No copydown created for initialised object 'seed'. Initialization data lost.

What am I missing? I don't understand what 'copydown' is.

Steve
Labels (1)
0 Kudos
Reply
2 Replies

555 Views
stevec
Contributor III
I have declared and initialised 'seed' (=10000) and used srand(seed) prior to the rand() call. I still get the same warning.
0 Kudos
Reply

555 Views
CrasyCat
Specialist III
Hello
 
Are you linking the standard startup file (start08.o) to your application or are you using your own startup function?
 
Are you building with -D__ONLY_INIT_SP?
 
seed is a global variable and as such need to be initialized at Startup.
 
In fact in order to get global variables initialized at Startup I would recommend you to link the standard startup function to your application and to use the standard ANSI c startup code (build without 
-D__ONLY_INIT_SP).
 
This should avoid the warning.
 
CrasyCat
0 Kudos
Reply