I have a problem with storing data in an EEPROM on a Fujitsu 16-bit microcontroller. Writing bytes to the EEPROM is not the problem, I can write and read data bytewise with no problem.
We are using an enum of dword
s to store different variables in the EEPROM and they are all 4 bytes long. For each variable we want to store up to those 4 bytes of space. This is pretty much not good, because when I only want to store a flag (one bit) or a variable which is only one byte long, it still uses up four bytes.
The reason we use this four byte technique is so we know on which adress the variable is stored that I want to access. This works OK, but it has quite some downsides.
One is the wasted space, and another one is the problem which arises when I'm working with structs.
For example I have a struct like
typedef struct {
attenuator_whichone_t attenuator;
char* attenuatorname;
servo_whichone_t associated_servo;
ad_ad7683_whichone_t associated_adconverter;
word item_control;
word item_mode;
word item_position;
} attenuator_info_t;
and initializing it like:
static attenuator_info_t constinfo[_NUM_ATTENUATOR_WHICHONE_] = {...}
With the code we are using right now, we would need to save every value individually. Hence breaking the structure apart. I would really want to store that structure as it is. (and a couple more we have in the code).
From my understanding I would need a filesystem for that. A Google search gave me some examples like the microFAT and so. This is, in my opinion, overkill.
Storing the struct with sizeof and iterate through all the bytes would be just fine, but then, how do I handle the problem of knowing where the structures are in the EEPROM? So some sort of file system is probably needed. Isn't there anything smaller? Or some trick? The variables are with a fixed length anyway. So that's why I was wondering if there is some nice and simple way to store those structs.
I hope I could elaborate on my problem enouph.