cancel
Showing results for 
Search instead for 
Did you mean: 

HardFault_Handler upon updating variables inside DMA Callback

DCont.1
Associate II

Hi,

I am currently implementing a guitar effects pedal using the STM32F446RE and the PCM3060 as my CODEC.

I have gotten everything to work, except when I try to adjust the following parameters

cf0_lim = (int)(time*l_CB0);

cf1_lim = (int)(time*l_CB1);

cf2_lim = (int)(time*l_CB2);

cf3_lim = (int)(time*l_CB3);

ap0_lim = (int)(time*l_AP0);

ap1_lim = (int)(time*l_AP1);

ap2_lim = (int)(time*l_AP2);

inside my DMA. For some reason, I cannot update these parameters, or anywhere else in my code. I tried updating them outside of the DMA callbacks for my CODEC and also on the while loop.

I am pretty sure these are the parameters that are triggering the HardFault error because whenever I comment them out the code runs fine.

I am able to update the "time" and "wet" variables whilst the DMA is running. This is fine, however, without updating the cfx_lim and apx_lim variables, I can't do much to apply this changes to the current effects that are being used for the reverb effect.

Is there a reason why this is happening? I have attached my entire code.

3 REPLIES 3

The processor has registers that tell you exactly what it doesn't like, and where it faulted, and the general purpose registers at that point.

Look at the disassembled code as the processor sees and executes it.

Shouldn't in-bound DMA buffers be volatile?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

In terms of making the buffers volatile, yes. I had forgotten to make them volatile. Thank you. In terms of the register debugging, as far as my knowledge goes, the Hard_Fault is held in the pc register, which I suppose stands for program counter. However, am not sure how to go from here in terms of debugging.

Could it be I can search for this issue in the stack?

TDK
Guru

Debug the code, pause when it's in the hard fault handler and inspect registers for the reason.

You can use Window -> Show View -> Other to bring up the Fault Analyzer.

The call stack should also give you insight into where the issue occurs.

If you feel a post has answered your question, please click "Accept as Solution".