AnsweredAssumed Answered

Vstr instruction causing hard fault with stm32f407

Question asked by Pablo Cottens on Mar 16, 2018
Latest reply on Mar 22, 2018 by Clive One



I have an olimexe407 board and I am creating an array with floats (-1 to 1) that I'm calculating and then I am converting them to q31 into 3 different buffers.


I initially tried doing this converting it to one buffer and then calling arm_float_to_q31 and it worked, I verified the values manually, by code and by converting them to float from q31 and comparing the initial float buffer and the final one. The problem is that when I added the second and third buffers, I noticed that it was causing a hard fault.


After a while of debugging I noticed that the fault occurred whenever it was doing a vstr instruction (even though it had been doing other float instructions properly until then). At that moment I was doing optimization level 3, which is probably why it was generating the vstr instruction (haven't tried it again after optimization went to none), but still ... the compiler shouldn't be generating an incorrect instruction (IF IT IS and incorrect instruction).


As stated above I am using the olimex board, and I am programming it on eclipse with the arm-none-eabi- tools


PS: At some point I also tried moving a bunch of floats to a struct and in the final float it did the vstr instructon and it failed the same way, that's how I think that it's probably not a library bug (thounsands of people use it ... probably someone else would've found it waaay before me). I turned this around by forcing a memcpy instead of a simple assignment.