2020-12-22 03:26 AM
I have a system with several SPIs and logging of data to SD Card. During a test which logged data over night the system ran into a Hard Fault (INVSTATE) after some hours.
My questions:
What is the reason for an INVSTATE Hard Fault?
How can I detect, where the fault occurred?
I dumped the Memory of the Stack (MSP = 0x2406DB20) and the registers - see screenI see adresses like 0x0808C3E9 in the stack, but not at the address where MSP is pointing to.
How do I have to interpret this?
2020-12-22 04:23 AM
Stacked PC is zero but that's consequence of the faulty code. LR is 0x0808C3E9, it means that instruction which called the routine which caused the fault, is at address jus before 0x0808C3E8 (bit 0 being set means Thumb mode).
JW
2020-12-22 04:45 AM
Thank you very much, Jan! Now I already assume the reason for the Hard Fault... Will check for a solution.
2020-12-22 06:05 AM
Calling a NULL pointer? Should check callback or stucture elements are non-zero or assert if not within expected ranges.
See previous routines to dump registers often quicker than debug view.
2020-12-22 06:45 AM
Hm... I can see from the linker list that the area where 0x0808C3E8 is located must be within HAL_SPI_IRQ_Handler:
i.HAL_SPI_IRQHandler 0x0808c30c Section 0 stm32h7xx_hal_spi.o(i.HAL_SPI_IRQHandler)
i.HAL_SPI_Init 0x0808c548 Section 0 stm32h7xx_hal_spi.o(i.HAL_SPI_Init)
How could it happen that the HAL is calling a NULL pointer?
The address of my HAL_SPI_RxCpltCallback/TxCpltCallback is not taken from an address pointer in RAM! I am not using DMA, where this would apply.
NULL pointers are checked in the HAL as far as I can see.