• 0 Posts
  • 1 Comment
Joined 2 years ago
cake
Cake day: June 22nd, 2023

help-circle
  • The way I have done it in the past. Rearrange all struct members from the largest to smallest data size. Do a sizeof the struct to make sure it is what you expect. You can look at the memory map too if your compiler provides it. Point an unsigned char (uint8_t) pointer to the first member of the struct or the variable name of the struct casted as a uint8_t. Then move the data into whatever the EEPROM or flash pages the data needs using the sizeof the struct and the size of the page for the non volatile storage. Sometimes I make a temporary array of the structs if I’m going to do several on a page. Then either copy directly into my ram overlay or just return the data if it is like a lookup or whatever.