2022-09-16 01:39 PM
Hello,
A simple question regarding STM32CubeIDE and its compiler.
For example, I declare:
typedef volatile struct {
uint8_t myVariable;
} myType;
Live Expression-Type shows myVariable as uint8_t only. It should make all the members inside volatile as the theory says.
Nevertheless, when I declare:
typedef struct {
volatile uint8_t myVariable;
} myType;
Live Expression-Type shows volatile uint8_t. This is also true for a pointer to the structure.
I would like to ask whether it is the matter of indication or the volatility is not being applied for sure. I am trying to solve some erratical ifs and flags skipping in the main while loop when they are being accessed by several interrupt routines.
2022-09-16 02:11 PM
It's using GNU/GCC
Details of the variable would be in the debug records of the object, perhaps less so in the symbols. You could inspect via objcopy or fromelf, etc.
You first makes myType volatile, right?
You could also inspect the generated code to review how treats pointers and sub-fields with the structure.
There might be write-buffer, and caching effects, depending on the MCU.
volatile means you need to re-read the content on each use, it's not a more general fencing function.