2023-11-02 10:49 AM - edited 2023-11-03 05:42 AM
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
2023-11-02 11:05 AM - edited 2023-11-02 11:07 AM
Look at what's actually faulting. The MCU instructions and registers.
Do regular printf() or putchar() work, or do they fault too?
Keil, but the mechanics are the same.. https://github.com/cturvey/RandomNinjaChef/blob/main/KeilHardFault.c
2023-11-02 11:10 AM - edited 2023-11-02 11:13 AM
Thank you for your reply!
With breakpoints, the compiler is faulting exatcly when printf is executed, it doesn't matter what its argument is ... I tried as well to write printf("Hello \n"); and HardFault occours.
Does that answer your comment? Because it is not very clear to me when you say "verify using instructions and registers" and what should I do with the code in the link you sent me
2023-11-02 11:17 AM
I mean at the MCU level not at the C function level. Something with finer granularity, and not the broad side of a barn..
Do you enable the FPU in your SystemInit() code?
Has it linked the appropriate C library. 32-bit ARM code will fault a CM4F processor.
The call to printf() or the code within the function?
Does the CubeIDE provide some sort of Hard Fault Analyzer function or window?
2023-11-02 11:17 AM
Another thing, in all the other projects I have, printf works correctly.
Here that I imported the arm_math.h libraries etc. following this tutorial ... it does not work. Maybe is there some incompatibility problem?
2023-11-02 11:24 AM
I can send you pictures of the functions you mention, but I have no idea what to change/check here
2023-11-02 11:27 AM
the CubeIDE has many great things (...if they are working...) :
2023-11-02 11:34 AM - edited 2023-11-02 12:29 PM
Now I don't understand if the problem is in the code I wrote (main.c) or in some other file
Thanks @AScha.3 I didn't know about this function because I never needed it
2023-11-02 02:53 PM
The last thing on the call stack is malloc_r (malloc) so check the pool (size, address....). Where _sbrk() is implemented? Do you have sysmem.c ?
2023-11-02 03:08 PM - edited 2023-11-02 03:10 PM
_sbrk() is in sysmem.c