Showing results for 
Search instead for 
Did you mean: 

printf hard fault


Whenever the compiler executes

printf("frequency %f: %f \n", ((float32_t)(i * SAMPLING_RATE) / FFT_BUFFER_SIZE), output_fft_mag);

it goes to HardFault.

I attach main.c and syscall.c

All the code that we need to analyze is inside the function void get_sineval_FFT2()


Here's the problem:


EDIT: The problem is only there when I try to printf floats ... whereas with normal strings or ints everything goes





This is very strange. Floats passed to printf  must be automatically converted to doubles. Something else goes on there. The float 'coprocessor' not enabled by startup?


Now it works:


After so many trials I don't really remember what I changed from the main.c I had posted in the first post of this thread, maybe I was using temp while I should have used temp[i] ? .. I don't know.

In any case, thank you for your efforts and help.

This is a late-in-the-game longshot. Is your FFT producing double or long double complex results as successive real and imaginary parts in the buffer ?

include <complex.h> support is not in your main.c.

The FFT produces a vector like this: [a0, b0, a1, b1 ...] where a0 is the real part while b0 is the imaginary part of the number