Maybe I have some setting wrong in my project. At the beginning of my main source file, I include a header that declares several variables as externs. Then I declare and initialize them after the #include.
Main Source:
#include <header.h> ... const char DEVICE_NAME[] = "ELC"; const char VERSION_NUMBER[] = "F1.0M1.0"; const char CONTROL_PANEL = 1; ... void main(void) { ... }
Header (header.h):
#ifndef _HEADER_H #define _HEADER_H ... extern char DEVICE_NAME[],VERSION_NUMBER[],CONTROL_PANEL; ... #endif
The variables are then used in implementation code in another file. This other file and the header are common to several projects that I'm working. (I have restructured my projects per our last discussion.)
The problem that I'm experiencing is that all of the data is initialized to 0 at the beginning of main() rather than the specified values. I don't have any of the .A51 initialization files in my project, so what could be causing this?
Thanks.
You might be better off not explicitly initializing that buffer at all. An initialization to an explict {0} serves no particular purpose anyway --- the result is the same as if you hadn't initialized it all, since the implicit default initialization to all-zeroes would have done the same job, and without wasting several kilobytes of zero bytes in the code image.
... how much xdata do you actually have?
Erik
You might be better off not explicitly initializing that buffer at all.
I see your point. I thought it was better to be safe.
I'm using the SciLabs C8051F020, which has 64K each of program and data memory. My programs are building to about 12K for the largest program. Other devices requires significantly smaller builds.
I'm using the SciLabs C8051F020, which has 64K each of program and data memory
www.silabs.com/.../C8051F020_Short.pdf clearly states it has 4k of xdata + the usual 256 of (I)DATA
That might likely be my problem then. I misread the 64K external memory addressing note.