2021-01-17 10:01 PM
Hello community,
I am trying to write time critical code which involves an STM32f412ZG Nucleo 144 board and a RPi communicating over SPI protocol. I have an IMU sensor communicating to STM32 board via I2C interface.
I have 3 tasks, which function as follows,
The tasks 1 & 3 when executed, run smoothly and outputs expected behavior. The task 2 when executed individually also runs smoothly and outputs expected data. However, when these tasks are integrated, there is a hardfault error which occurs as soon as the code is executed.
I am new to this kind of programming and finding it very hard time to debug the issue.
I suspect that the DMA is causing the issue after looking in to the call graph of stack analyzer.
Below is the call graph snapshots.
I request the community to help me debug the issue. Please let me know if more details are required.
Thanks,
Ashish Kumar
2021-01-17 10:10 PM
Really doesn't look like a call tree at the fault
Instrument the Hard Fault Handler (I've posted code dozens of times)
Have it output fault state to serial console.
Inspect the disassembled code at and prior to the faulting PC, see what it is doing, determine if the fault address is relatively consistent or not.
Check things like adequate stack depth.
For consistent failure check C code at site, if pointers can be checked or qualified.
2021-01-17 10:59 PM
Hi @Community member ,
Thanks for your quick response.
I request you to kindly provide a link to the topic. Since, I am a newbie with the real time programming, I am not sure how to inspect disassembled code. Could you also help me with any general documentation to do it.
2021-01-17 11:07 PM
https://community.st.com/s/global-search/hardfault_handler_c
ARM has Technical Reference Manuals
Here mostly we're looking to see the instruction flow, likely to be failing on a LDR/STR (load or store), look also a C code at failing address.
Debugger should have a "Show code at Address" type interface