We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi everyone, j developed a C program that use the philips 87LPC764 8051 derivative. This micro needs to store at specific addresses in code memory 2 bytes for the configuration options (type of oscillator, speed etc.)...how can j do this? Maybe using the "_at_" keyword? Any ideas welcomed bye! Massimo.
Mark wrote: "I asked why you'd want a *variable* at a particular address." As I said, judging by the number of times the question gets asked here, there's a lot of people who do want to do it! They don't usually say why they want to do it, so it's hard to say whether they have good reasons! I agree that it's probably not wise to rely on the 'C' runtime to initialise your memory-mapped peripherals, but I can think of 2 applications where an _at_ with an initialiser seems reasonable: 1. Cases such as the original post here, where some configuration values need to be set in a specific location - especially if it's in ROM; 2. To place some sort of "signature" (eg, version info) into a known location in ROM.
1. Cases such as the original post here, where some configuration values need to be set in a specific location - especially if it's in ROM; I think that this is best handled in the startup code along with the reset of the chip initialization. Jon
Andrew wrote: As I said, judging by the number of times the question gets asked here, there's a lot of people who do want to do it! They don't usually say why they want to do it, so it's hard to say whether they have good reasons! True, so let's show them alternatives that they can have now. For case 1: For the ROM case linker will create an image size large enough to capture the _at_ address. On a 64kB ROM this may not pose a real problem, but in principle I don't like padding out my image (.bin) just to get up to the checksum value up at 0xFFFE. What if I have to download this upgrade image over a slow link? For the RAM case, be explicit and just do it at run-time. I, again, stipulate that no one in their right mind would allow some memcpy routine to initialize memory mapped I/O addresses in XDATA. As for case 2: We really need to get comfortable with .a51 files. :-) - Mark