I can set a variable in the ROM area as following: #define END_CODE_SIZE 0x3FFF char code CRCbyte _at_ END_CODE_SIZE How do I set its value to says 0xAA? I can do this: char code CRCbyte = 0xAA; Then The variable is not allocated to the END_OF_CODE. Thanks for reading this. HN
I think the easiest way to do this is to place the 'variable' in a source file on its own, then direct the linker to place the resulting segment at the correct address. Isn't it a shame that Keil doesn't allow initialisers with the _at_ keyword? Stefan
The following knowledgebase article describes how to do this for a ROM checksum. It will work for a ROM CRC as well. http://www.keil.com/support/docs/494.htm One problem with doing this all within your C program is that your program does not know the correct CRC/checksum value. Jon
I also found another way. I create an assembly file with code as: PUBLIC CrCValue CSEG at LOCATION CrcValue: DB VALUE END Then in C code, I can use: extern char CrCValue. It works. Too bad I can not use #ifdef, ... to have different CRC values for different targets. Thanks.
"One problem with doing this all within your C program is that your program does not know the correct CRC/checksum value." Yes, but many of us want to store compile time constants at specific addresses for a variety of reasons. We don't want to run separate utilities after the build, muck about with linker directives or resort to assembler. We just want to write: unsigned char code somebyte=0xaa _at_ 0x3fff; Please? Stefan
That's a good idea. It's not that the keil software guys can not do it or it is too hard. It's just that they may never think about it and how convenient for us to use it in whatever way we want to. I hope the Keil technical supports monitor these mails let their software gurus know. HN
Don't worry, Keil are well aware that a lot of people want this facility. They don't seem keen to implement it though. This subject has come up time and again on this forum. Stefan