Misbehaviour at different optimisation levels
Hello.
I have a problem with the different optimisation levels.
I am programming the STM32F103ZET controller and using SMTCubeIDE V1.13.2
A controller pin triggers an external interrupt. This interrupt calls a function that sets a variable. This variable is queried in the main while loop.
If I compile this with the optimisation -O0 or -O1, then my program works. With all other optimisation levels, the recall function is still called, but the variable no longer seems to be changed, as no change takes place when querying in the main loop.
Here are my functions:
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
// Interrupt for USB connection
if (GPIO_Pin == USB_ERKENNUNG_Pin)
{
// Check if callback is defined
if (p_eehl_interrupt__callback_usb_connect != NULL) {
(*p_eehl_interrupt__callback_usb_connect)(HAL_GPIO_ReadPin(USB_ERKENNUNG_GPIO_Port, USB_ERKENNUNG_Pin) == GPIO_PIN_SET); // Calling the callback function
}
}
}
static void main_func_recall_usb_connect(void)
{
struct_main.struUSB.bUSB_Verbunden = true;
struct_main.struUSB.bUSB_VerbindungGeaendert = true;
// If I control an LED via a pin here, this works at every optimization level
}
Is this a bug in STM32CubeIDE or have I done something wrong in my compiler settings?
Thank you very much.
