Hi everyone,
I was reading about bit fields and I tried to apply them to my firmware for practice. So I created a two member struct and define the members to be one bit in lenght. Finally, I created an instance of the struct and initialized it
Code:
struct FM_states {
uint8_t prevState_FMC:1;
uint8_t prevState_FMH:1;
};
struct FM_states FM_state {
.prevState_FMC = 0,.prevState_FMH = 0};
After compiling a noticed that the flash memory was higher than before using the bit fields
This is the flash occupation with bit fields:
This is flash occupation with out bit fields (24 bytes less):
So, in general bit fields do not reduce memory size?