I am trying to put the software version number (a string) in the code flash at a specific location. When I leave off the "_at_" specifying the address, it works just fine. When I include the "_at_" I get the following error message:
*** ERROR C274 IN LINE 39 OF MAIN.C: 'text': absolute specifier illegal
The line of code is: char code text[20] _at_ 0x7d00 = "Hello World\n";
This line if code is right out of Keil's C251 User's Guide. I'm using an 8051 (C51 compiler) so perhaps there is a limitation there.
Oddly enough, if I remove the initialization, as below, it compiles just fine. char code text[20] _at_ 0x7d00;
Any ideas?
Cannot be done. Just read the User's Guide:
The following restrictions apply to absolute variable location using the _at_ keyword:
1. Absolute variables cannot be initialized. 2. Functions may not be located at an absolute address. 3. Bit variables may not be located at an absolute address.
Perhaps I can put this in its own source file and locate the segment.
In case anyone cares, here's how I solved it. Create separate file, Version.c, to hold the global variable.
static code char pVersion[35] = "Program Version: 1.0";
Locate this module near the end of flash using the command
CODE( ?CO?VERSION(0x7F00))
Hopefully the linker will complain if there's a conflict.
Cheers.
Always a good idea!
;-)
User Guide page: http://www.keil.com/support/man/docs/c51/c51_le_absvarloc.htm
Knowledgebase article: http://www.keil.com/support/docs/301.htm