Editing Embedded Programming Tips and Tricks for Beginners
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 | + | 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 | + | 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 | + | 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 | + | The only solid solution is to write your own eeprom read/write/update functions that work based on some fixed address. |