I encounter frequent hard fault as soon I use CAN & USB at the same time. I'm using FreeRTOS on a MK64F MCU.
I tried to analyze fault registers to find out the cause of the hard fault but I'm not sure to interpret the value of BFAR.
See below the steps when it is stopped in HardFault_Handler function:
1. Inspect Configurable Fault Status Registers
GDB: print/x *(uint32_t *) 0xE000ED28
Entire CFSR 0x008200
with [ UFSR | BFSR | MMFSR ]
2. BusFault Status Register (BFSR) - 0xE000ED29
GDB: print/x *(uint8_t *) 0xE000ED29
7: BFARVALID 1
1: PRECISERR 1
3. Bus Fault Address Register (BFAR)
GDB: print/x *(uint32_t *) 0xE000ED38
should hold the address which triggered the fault ?
See my linker script from SDK:
/* Specify the memory areas */
m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x000FFBF0
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000
m_data_2 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00030000
I would assume it should point somewhere in m_text region...
Any ideas ? What am I doing wrong ?