STM32H7 unexpected fluctuations of a constant float / double variable
Hello,
I am currently having a problem with a float / double variable, involved in a Timer interrupt, within a Nucleo H743ZI2 MB1364E.
Considering the variable ‘double test_fluctuation_variable’, declared at the very top of the main.c, this variable is updated (and hold constant) inside a timer function as:
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
test_fluctuation_variable = (double) 2.0;
…
}
Depending on the initialization value of this variable, two cases are observed in the debug mode:
* In the case ‘double test_fluctuation_variable = 0’, the variable unexpectedly fluctuates: see video ‘STM32H7_fluctuation_with_ZeroInit’ of the debug mode attached;
* In the case ‘double test_fluctuation_variable = 0.1’, the variable remains stable to the expected assignation: see video ‘STM32H7_constant_with_Init’ of the debug mode attached.
It seems that the initialization value may create a different 'behaviour' of the variable even if it is set as constant; this variable is only used one time in this particular timer function. This problem also occurs if this variable is assigned in the main while(1) loop...
The following peripherals are running: FDCAN, RS232 and ADC.
The current software configuration is:
- CubeIDE Version: 1.11.2 Build: 14494_20230119_0724 (UTC)
- STM32H743ZITx / STM32Cube FW_H7 V1.11.0
- MacOS Ventura 13.2 (22D49)
Thank you in advance
Best regards,
Loïc
