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.
I don't have any of the .A51 initialization files in my project, so what could be causing this?
That very thing might just be causing it. INIT.A51 does the job that's not being done in your project. So how about you try putting it into your project and see if that makes a change?
So how about you try putting it into your project and see if that makes a change?
No change. All of my preset string variables are still zeroed out. Is there anything more that I need to do than just add it to my project?
From the documentation, it seems like INIT.A51 clears all of the memory at device startup. I don't want it cleared; I want it to initialize properly.
Is there anything more that I need to do than just add it to my project?
It has to be the last entry in your project. Otherwise it won't work.
From the documentation, it seems like INIT.A51 clears all of the memory at device startup.
I don't know which documentation you're referring to, but no, that's not what INIT.A51 does. It initializes explicitly initialized variables.
View all questions in Keil forum