1
votes

My firmware for stm32f103 results in hard fault. Here is the line of code that crash execution:

 float shuntResistance = p[SHUNT_RESISTANCE];

where p - is global array of floats:

float p[CONFIG_NUM_PARAMS];

There is dissaembly while debugging:

0800177c:   ldr r3, [pc, #332]      ; (0x80018cc <adcSetConstants+336>)
0800177e:   vldr s10, [r3, #48]     ; 0x30 ; on that instruction program results in hard fault

Here is compiler flags:

-c -fmessage-length=0 -mthumb -mcpu=cortex-m3 -mfloat-abi=softfp -ffunction-sections -fdata-sections -fsingle-precision-constant

Linker flags:

-Wl,--static,--gc-sections,-Map=${ProjName}.map,-T../stm32_flash.ld -fmessage-length=0 -mthumb -mcpu=cortex-m3 -ffunction-sections -fdata-sections -fsingle-precision-constant -Dprintf=iprintf -u _printf_float -lc -lnosys -lc

Used compiler is launchpad's arm-none-eabi-gcc. Used IDE is eclipse. What is the cause?

1
Can you post the contents of your registers after the hardfault?rost0031
My understanding is that the cortex-m3 does not have an fpu. en.wikipedia.org/wiki/ARM_Cortex-Mold_timer
@dwelch: that is correct but you can still use soft fpu library with cortex M3.rost0031
can you reduce the code to just something that breaks? what other command line options have you used? reduce the command line options to something that still breaks or works and then evaluate what you really need or of two conflictold_timer

1 Answers

1
votes

Here is compiler flags:

-c -fmessage-length=0 -mthumb -mcpu=cortex-m3 -mfloat-abi=softfp

Your MCU is a Cortex M3, which has no FPU. You need to use -mfloat-abi=soft. The "softfp" option uses FPU instructions which will not work for you.