|
From: | Massimo Medini |
Subject: | [avr-gcc-list] Initialized data and > 64k program |
Date: | Fri, 14 Feb 2003 10:43:26 +0100 |
Hello to everyone.
I don't know if this is pertinent, but I have a
curious problem.
Some routines are working fine on an ATMega103, at
least until I use less
than 64 kbytes of Flash memory.
They stop to work when I approach the 64 kbytes
barrier.
The first try was to use the latest version of
avr-gcc, hoping in an already
corrected bug. The latest version had exactly the
same result.
So, I didn't switch to the latest version and keep
investigating with
version 2.95.2 , which I know better.
After some debug, mainly using an hardware output
to track when
the program stops, I found that the problem
occurred in a function.
To be concise, consider a code like the
following:
unsigned int QQ_SP[MAX_TASK]; .... more data .... void TaskDoMultiTasking(void){ int i; for( i=0; i<MAX_TASK; i++){ if( TaskState[i].State==TASK_ACTIVE ) { QQ_ActiveTask=i; QQ_ActiveSP=QQ_SP[i]; <-- this will be the problem QQ_MultiTaskIsRunning=1; QQ_JumpOnTask(); } }
}
it translates in the following assembly
portions:
126 .section .data 127 .LC0: 128 0002 0100 .word 1 129 .LC1: 130 0004 0000 .word QQ_SP 131 .section .text ......... 149 00c6 E090 lds r14,.LC1 149 0000 150 00ca F090 lds r15,(.LC1)+1 ............ Following the code in the AVR Studio, the hidden (not explicitily requested) variable .LC1 holds NULL when the program tries to load the address of the array QQ_SP. I followed the program also in the startup, and I have that (in the simulation) the address of .LC1 is filled by zero right when the runtime initializes the data in SRAM. Other data are normally filled with the correct values. It seems that only the hidden variables like .LC0 are affected. It could help to know that no one of the arrays use Flash memory past of a few kylobyte. Only the code is crossing the 64 kbyte boundary. Thanks to everyone who could help. Massimo Medini |
[Prev in Thread] | Current Thread | [Next in Thread] |