This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to assign initial values in code memory with specific location?

I want to define some values in code memory with specific location. For example

code unsigned char MyArray[] _at_ 0xF000 = {0x01, 0x02};


After that, I can use "MyArray[0]" and "MyArray[1]" to access the memory at 0xF000 and 0xF001.
How can I achieve this?

Parents
  • It would be helpful if you would explain why you want to do this.

    If you explained what you're actually trying to achieve, people may well be able to offer more appropriate suggestions.

    Yes, the are perfectly valid reasons to do this (Per has already given one) - but there are also very many cases where it is not necessary at all...

Reply
  • It would be helpful if you would explain why you want to do this.

    If you explained what you're actually trying to achieve, people may well be able to offer more appropriate suggestions.

    Yes, the are perfectly valid reasons to do this (Per has already given one) - but there are also very many cases where it is not necessary at all...

Children
  • "(Per has already given one)"

    LOL. Sorry, I'm not posting under the Silly Sausage alias :)

    But storing a checksum, version etc at a fixed location allows a firmware updater to verify that the correct file is downloaded, and that it hasn't been broken in transfer.

    It can also be used by the actual application to validate itself and possibly generate an alarm if a checksum error is found. If the unit is operating dangerous equipment, it may be very important that the firmware decides to lock up if a checksum test fails, do avoid endangering human life.

    With internal tests using crc or stupid checksums, the need for an absolute location can be removed by making sure that the crc or checksum always results in zero. But that makes it impossible to use the checksum/crc as an additional control that a file has the correct version. Without automatic build tools, the developer may have forgotten to step the printed version number...