I am working on some C code for a 16 bit microcontroller. When I debug the application on target I end up hitting an AddressError ISR. I read the data sheet and it says that this can happen if you try to read or write to a 16bit value that is aligned at an odd memory address. I think I understand what that means, but it just doesn't seem right. Wouldn't mean that if I were to make a struct like this:
struct foo{
uint8_t thing1;
uint16_t thing2;
};
that I would never be able read or write to thing2 without an error? If not, does that mean the compiler will automatically pad 8 bits between thing 1 and thing 2 so that thing two is aligned properly on an even address? If that is the case, then how would an address error ever occur?