Hi,
I'm using Keil IDE V4.23.00.00.0.
If I declare some static array in module A like: volatile static unsigned char MyArray[9] then all works fine.
If I declare it like: volatile static unsigned char MyArray[8] then another module B generates a HARD FAULT interrupt.
Module B does not use or has any connection with module A.
If I look in the .map file I see:
MyArray[9] .bss 0x20003a40 Section 500 f991_dma1forusart2.o(.bss) .bss 0x20003c34 Section 9 fa30_pccommunicator.o(.bss) MyArray 0x20003c34 Data 9 fa30_pccommunicator.o(.bss) .bss 0x20003c40 Section 96 libspace.o(.bss) HEAP 0x20003ca0 Section 512 startup_stm32f10x_xl.o(HEAP) MyArray[8] l_fpComShtRcvStsRepOptSkt 0x20000224 Data 4 fa30_pccommunicator.o(.data) MyArray 0x20000228 Data 8 fa30_pccommunicator.o(.data) .data 0x20000230 Section 351 fa40_comsheet.o(.data)
so there definitely seems to be a difference in interpretation as with the faulty [8] no '.bss' is used which according Wikipedia has to too with static declarations.
Who can help me out?
Thanks,
Henk
Where does the program crash? Maybe the shift in the location of the entire memory map exposes a problem somewhere else, and the crash is only an indirect sult of something else. Did you isolate the exact failure location?
I removed module A from the project. Now module B crashes each time on startup. ;-) Module B uses interrupts (reading sd-card by SDIO) and I cannot find the crash moment with the debugger. It could be some timing issue.
I wonder if there is some debug option that shows what instruction or function was executed prior to the Hard Fault error.
There are a couple of threads in this forum about exception handlers, describing how you from an exception handler look at the registers to find out which instruction that caused the exception.
Then you can see if you did an access (read or write) to non-existing memory, or if you did an unaligned access or if the processor picked up an invalid instruction, ...
Got it!
finally I managed to localize the error. When emptying the function which somehow caused the crash the application still crashed. Replacing this function by a dummy function has no effect. Removing the function call, then no crash occurred... So now I really got suspicious and increased the stack size from 0x400 to 0x500. Lo and behold....it works!!!
thanks for listening,