I'm using codewarrior to compile for the HC12, and I have two 120 element arrays: score and dur. I have initialized them in the typical fashion: unsigned int score[120] = { ... }; When I try to compile it, however, I get a linker error that says "L1981: No copydown created for initialized object "score". Initialization data lost." I can't figure out what that means or how I can make it so it creates a copydown. Note that this program compiles and seems to set values fine when I place them into main(), but I need them to be global variables because they are accessed by an interrupt.
Asked
Active
Viewed 732 times
2
-
Been a while for me, but have you assigned the arrays to a segment/address in the .map file? Or are you out of memory? – Potatoswatter Mar 07 '13 at 03:32
-
Nevermind, I was able to fix it. For anyone else who might come across this, you need to make the variables "const" or it will immediately delete the contents of the arrays. CodeWarrior is so friggin' finicky, I swear. – user702905 Mar 07 '13 at 03:33
-
1Actually it's a big difference. `const` array goes into Flash, whereas a non-const one goes into RAM. I would guess that the "copydown" is initialization code that copies from Flash into RAM at startup. – Potatoswatter Mar 07 '13 at 03:35
-
That makes perfect sense. I just wish the error was more verbose about what it was telling me to do. – user702905 Mar 07 '13 at 03:37
-
@user702905 You should post this as the answer to your own question, to help future readers. – Lundin Mar 07 '13 at 13:34
1 Answers
1
There are two likely reasons:
- Either you managed to declare this variable on the stack (bad idea) or in a memory segment that is too small to contain it. Consider placing large variables like these in dedicated RAM segments, by altering the .prm file.
- Or you have created a Codewarrior project with "minimal" startup code. If you do so you pick a non-standard setup where the initialization phase of objects with static storage duration is removed.

Lundin
- 195,001
- 40
- 254
- 396