This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

malloc() causing HardFault

Hi,

I work on a project for the nRF52832 with Keil µVision using ARM Compiler V5.06 update 2 and nRF5 SDK 11.

In a module I allocate quite some memory using malloc() for signal processing (SP). Upon user request, this mode ends and with that I free() up all the memory allocated previously. Upon another user request, I enter the SP mode again and do my malloc() calls again.

This is when it happens that one of the malloc() calls causes a hard fault. It does not return a null pointer (as it should if heap was exhausted), but simply fails. (Some of the last assembler steps in the debugger are attached below.)

I already tried to change heap and also stack sizes (based on a comment in https://devzone.nordicsemi.com/question/39385/checking-for-memory-usage-on-runtime/), but no success.

What can be the cause and how do I help the situation?

Thanks, Tamas

image description image description image description image description image description image description image description image description

Related