Editing Embedded Programming Tips and Tricks for Beginners

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 189: Line 189:
 
If you are using the EEMEM attribute to put your variables and or arrays into the EEPROM memory instead of FLASH you need to keep in mind that you are giving the compiler the right to choose the exact memory location in EEPROM where they are stored.
 
If you are using the EEMEM attribute to put your variables and or arrays into the EEPROM memory instead of FLASH you need to keep in mind that you are giving the compiler the right to choose the exact memory location in EEPROM where they are stored.
  
This means that, if in the future the compiler decides to store them in a different order or a new compiler version stores them in a different way, you will run into major problems. EEPROM data will appear in the wrong location and cause all sorts of confusion.
+
This means, that if in the future the compiler decides to store them in a different order or a new compiler version stores them in a different way you will run into major problems. EEPROM data will appear in the wrong location and cause all sorts of confusion.
  
This is especially a problem if you plan to distribute your application and allow users to flash new firmware. You can easily end up with multiple firmware versions storing data in slightly different EEPROM locations. This can sometimes go unnoticed until it's too late and data is corrupted.
+
This is especially a problem if you plan to distribute your application and allow users to flash new firmware. You can easily end up with multiple firmware versions storing data in slightly different EEPROM locations. This can sometimes go unnoticed until its too late and data is corrupt all over the place.
  
 
You can mitigate the issue a little if you put all of your EEMEM variables into a struct. This way you at least know they will be in the correct order.
 
You can mitigate the issue a little if you put all of your EEMEM variables into a struct. This way you at least know they will be in the correct order.
And one would assume the struct will always start from the same eeprom address. However this is still taking a big risk.
+
And one would assume the struct will always start from the same eeprom address. However this is still a little risky.
  
The only solid solution is to write your own EEPROM read/write/update functions that work based on some fixed address.
+
The only solid solution is to write your own eeprom read/write/update functions that work based on some fixed address.

Please note that all contributions to EEVblog Electronics Resource Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see EEVblog Electronics Resource Wiki:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please solve the following task below and enter the answer in the box (more info):

Cancel | Editing help (opens in new window)