cancel
Showing results for 
Search instead for 
Did you mean: 

(SOLVED) Sprintf with Floating Point Number enters infinitive loop in Bare-Metal Programming

FEvra.1
Associate II

The problem is about Sprintf with floating point number on STM32L452RET6P.

Although all settings are correct, sprintf doesn't work with floating point number only. Although it works on stm32cubeMX, it doesn't work on bare-metal program. It loops endlessly in the Default_Handler function. I'm about to go crazy. 

First sprintf properly works. But the second one does not. After second sprintf, I've traced back the code on the debugger and I can see that the DefaultHandler executes and traps the board in an Infinite_Loop as a result of WWDG_IRQHandler misfiring. 

Error message tells me "No source available for "<signal handler called>() at 0xfffffff9" , No source available for "_printf_float() at 0x8001124", No source available for "_svfprintf_r() at 0x8004c8e", No source available for "sprintf() at 0x8001d08" . I can't seem to solve this problem, do you have any idea?

 Program is below:
_legacyfs_online_stmicro_images_0693W00000dJvDpQAK.png
_legacyfs_online_stmicro_images_0693W00000dJvIpQAK.png 

Here is linker flags.

 -mcpu=cortex-m4 -T"/Users/fatih/STM32CubeIDE/workspace_1.2.0/microprocessors/2023/Bare_Metal/Bare_Metal_HCSR04/STM32L452RETXP_FLASH.ld" --specs=nosys.specs -Wl,-Map="${BuildArtifactFileBaseName}.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -u _printf_float -Wl,--start-group -lc -lm -Wl,--end-group

Compiler Settings:

 -mcpu=cortex-m4 -std=gnu11 -DDEBUG -DSTM32L452RETxP -DSTM32L4 -DSTM32 -DSTM32L452xx -c -I../Inc -I"/Users/fatih/STM32CubeIDE/workspace_1.2.0/microprocessors/2023/Bare_Metal/Bare_Metal_HCSR04/Drivers/CMSIS/Core/Include" -I"/Users/fatih/STM32CubeIDE/workspace_1.2.0/microprocessors/2023/Bare_Metal/Bare_Metal_HCSR04/Drivers/CMSIS/Device/ST/STM32L4xx/Include" -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb


_legacyfs_online_stmicro_images_0693W00000dJvDzQAK.png 

Here's a screenshot of the debug window.


_legacyfs_online_stmicro_images_0693W00000dJvDVQA0.png

10 REPLIES 10

I don't see call to SystemInit() in that screenshot with startup code either, but whatever, if it works. I don't really about the magics in IDEs to do these things.

Please select Tesla's post as Best, so that the thread is marked as solved.

JW