Can't run any program that uses floating point arithmetic in STM32F4219 (Cortex M4) (Solved)
I’m having and issue with floating point arithmetic with a Cortex-M4 CPU (STM32F429).
Starting with a clean project generated with CubeMX for STM32F429I DISC1 board, I have added to main.c a simple function to compute some sinusoidal samples:
{
int32_t i, cc;
float *ptr;
float phase;
ptr = &datad0;
phase = 2.0 * (float)M_PI*15e3/2e6;
i = 1024;
cc = 0;
while(i)
{
*ptr++ = sinf(phase * (float)cc++);
*ptr++ = sinf(phase * (float)cc++);
*ptr++ = sinf(phase * (float)cc++);
*ptr++ = sinf(phase * (float)cc++);
i -=4;
}
Also I have include “math.h” in main.c and checked “Use C math library (-lm)” option.
When debugging the program using a break-point just after calling this simple function, the CPU become freeze at all. It doesn’t respond to pause nor stop then I can’t watch results nor see where is the problem. The only way I have to take control again is to terminate the debug session, losing all information.
I have checked that MCU floating point options are right (fp hardware=fpv4-sp-d16, fp ABI=hard, instruction set=Thumb II).
My compiler flags are:
-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Dweak=”attributeweak” -Dpacked=”attributepacked” -DUSE_HAL_DRIVER -DSTM32F429xx -I../Inc -I../Drivers/STM32F4xx_HAL_Driver/Inc -I../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -I../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F -I../Drivers/CMSIS/Device/ST/STM32F4xx/Include -I../Middlewares/Third_Party/FreeRTOS/Source/include -I../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS -I../Drivers/CMSIS/Include -Og -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fmessage-length=0
and linker ones are:
-+-mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -specs=nosys.specs -specs=nano.specs -T”../STM32F429ZITx_FLASH.ld” -Wl,-Map=output.map -Wl,--gc-sections -lm
Tried with and without ARM_MATH_CM4.
Somebody has any clue where could be the problem.
Thank you.