2025-09-04
9:09 PM
- last edited on
2025-09-05
1:15 AM
by
Lina_DABASINSKA
I'm trying to figure out why the value 4.2 is returned as -2 when passed as a function argument. Could you please also provide a solution? The MCU is an STM32F302VET.
2025-09-05 5:56 AM
Is optimization turned off?
2025-09-05 7:14 AM - edited 2025-09-05 7:16 AM
Hello @bupark007
As mentioned by @TDK using high optimization levels can cause variables to be kept in CPU registers or even optimized away, making them difficult to inspect during debugging. To address this, try setting the optimization level to -O0 (no optimization) when debugging your code.
THX
Ghofrane
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-09-05 10:45 AM
I'd probably instrument, and call test cases with terminal output to confirm the functionality.
I think there are reported issues with the debugger's memory/expression view.
Check you have pulled libraries with sscanf / printf support of floating point.
Inspect code generated by the compiler for consistency, double check the casting of the math at each stage.