why _malloc_r() running from printf() access invalid address (0x800000) and causes BusFault
Hi,
I am testing ThresholdDetection example of FlightSense on Nucleo_STM32F401RE, the code works fine with default setting as 4x4 resolution in MX_53L5A1_ThresholdDetection_Process(). Changing resolution to 8x8, printf() goes into HardFault_Handler(), from debug console the instruction prior to exception handler is _malloc_r() accessing 0x800000 address. Increasing both heap and stack size to 0x8000 does not help.
However, adding printf() in main.c (i.e. prior to running MX_53L5A1_ThresholdDetection_Process()), the code works fine without exception.
My questions: (1) why printf() accessed invalid memory address after changing 4x4 to 8x8? (2) why adding printf() in main.c resolved it without exception? (3) how to identify the root cause?
Any help and suggestion is pretty appreciated.
Thanks~