jeudi 26 janvier 2017

unaligned to 32 bits write exception in cpp/embedded

I have the following union:

union {
    volatile  uint32_t  reg;

    struct {
        volatile  uint32_t  Var1 : 1;
        uint32_t : 3;
        volatile  uint32_t  Var2 : 4;
        volatile  uint32_t  Var3 : 8;
        volatile  uint32_t  Var4 : 8;
    } bit;
}unionA;

and I have cpp file which I can not change (I can change the h or the union). the cpp calls to a _register.unionA.bit.Var4.

within the assembly I see it tries to write to offset 16 (bits).

the CPU gives me an exception.

Is there any attribute/pargma/something else that I can place within compiler flags/h files so it will always write 32 bits and not the 8 bits with offset of 16

Aucun commentaire:

Enregistrer un commentaire