cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE: Different size of enum in "variables" and "expressions" views

MMart.3
Associate

Hello

I am debugging my project and I found a behaviour I can't understand.

I have a global struct (appModbusSlave). I can see it in "expressions". That structs has different kind of variables inside. One of them is a enumeration called "estado" (type MODBUS_SLAVE_ESTADO). Compilator gives it a size of two bytes (its address is 0x2000b544 and the next variable address is 0x2000b546).

0693W00000SuOMKQA3.pngWhen I send a pointer of that variable to a function, I can see the struct in "variables" view.

The point is that enum called "estado" has a size of 4 bytes (it begins en 0x2000b544 and the next begins in 0x2000b548.

0693W00000SuOLbQAN.pngYou can see that:

  • in "expressions" view (outside the function) "key_n_block" has a value of 65535
  • in "variables" view (inside the function) "key_n_block" has a value of 0.

Due to that, the program doesn't work properly

Is this a problem of the compiler? Is a problem of the code? Should I use "packed" attribute in?

Best regards

Best regards

1 REPLY 1
MMart.3
Associate

I have forgotten to say:

STM32L431RC

STM32CubeIDE 1.10.0