TCL Debug [C/C++ MCU Application] MCU GDB Debugger (1/25/12 2:17 AM) (Suspended) Thread [1] (Suspended: Signal 'SIGSTOP' received. Description: Stopped (signal).) 7 HardFault_Handler() cr_startup_lpc176x.c:356 0x000000f6 6 <signal handler called>() 0xfffffff1 5 main_loop() main.c:687 0x00006f4c 4 RIT_IRQHandler() RITtimer.c:45 0x00000250 3 <signal handler called>() 0xfffffff9 2 c_entry_main() main.c:381 0x00005c9e 1 main() main.c:1185 0x00008578 arm-none-eabi-gdb (1/25/12 2:16 AM) /home/luke/Desktop/moje/work/workspace/TCL/Debug/TCL.axf (1/25/12 2:17 AM) |
// adjust pulses_mod_* for speed pulses_mod_front = fabs(ceil(1.0 / (gps_data.speed * bolts_multiplier_front))); pulses_mod_rear = fabs(ceil(1.0 / (gps_data.speed * bolts_multiplier_rear))); if(pulses_mod_front > PULSES_MAX_SIZE_M1) pulses_mod_front = PULSES_MAX_SIZE_M1; if(pulses_mod_rear > PULSES_MAX_SIZE_M1) pulses_mod_rear = PULSES_MAX_SIZE_M1; // read wheels pulses_front_current = FIO_ByteReadValue(1, 2); pulses_rear_current = pulses_front_current & 0x0f; pulses_front_current = pulses_front_current & 0xf0; pulses_front_current = pulses_front_current >> 4; // calculate the change since last read (front) index = i % pulses_mod_front; pulses_front[index] = pulses_front_current - pulses_front_previous; // <-- HARD FAULT HERE! |
Facing similar issue like w.r.t hardfault and wrong memory access/broken memory kind of with MKV56 controller.
Did we have any solution/RCA for this issue by any chance?
Hi,
I know this is an old post, but I proceed to post my solution, maybe it is usefull for somebody.
I've had similar problems in a project I am working on. In my case, I get the HardFault issue, when an CAN IRQ start within a RIT IRQ.
I was working on a cpp project, and the CAN IRQ callback function was on a cpp file. I miss to include the compiler directive:
#if defined(__cplusplus)
extern "C" {
callback_function_declaration()
#if defined(__cplusplus)
}
#endif /* __cplusplus */
This is obviuly a mistake, due to the fsl_mcan driver is written in C, and the function callings in C work in a diferent way than in C++.
Unlucky, the call work with one level IRQ, making me getting a little be lost in the issue. But if the function call is within a second IRQ level, I guess something gets corrupt on the IRQ stack and then you get the HardFault.
Once added the "extern "C"" directive, everything works well.
TCL Debug [C/C++ MCU Application] MCU GDB Debugger (1/28/12 4:58 PM) (Suspended) Thread [1] (Suspended: Signal 'SIGSTOP' received. Description: Stopped (signal).) 2 <symbol is not available> 0x1fff0080 1 <symbol is not available> 0xffffffff arm-none-eabi-gdb (1/28/12 4:58 PM) /home/luke/Desktop/moje/work/workspace/TCL/Debug/TCL.axf (1/28/12 4:58 PM) |
[...] 1fff0074: movs r0, r0 1fff0076: movs r0, r0 1fff0078: movs r0, r0 1fff007a: movs r0, r0 1fff007c: movs r0, r0 1fff007e: movs r0, r0 1fff0080: ldr.w r4, [pc, #24] ; 0x1fff009c 1fff0084: ldr.w r5, [pc, #16] ; 0x1fff0098 1fff0088: ldr r6, [r4, #0] 1fff008a: and.w r6, r5, r6 1fff008e: str r6, [r4, #0] 1fff0090: ldr.w pc, [pc] ; 0x1fff0094 1fff0094: lsls r1, r0, #8 1fff0096: subs r7, r7, #7 1fff0098: itttt <und> 1fff009a: ; <UNDEFINED> instruction: 0xffffc3c0 1fff009e: and<und> r7, r1 1fff00a0: mov<und> r0, r0 1fff00a2: mov<und> r0, r0 1fff00a4: movs r0, r0 1fff00a6: movs r0, r0 1fff00a8: movs r0, r0 1fff00aa: movs r0, r0 1fff00ac: movs r0, r0 [...] |
// interrupt priorities #define RITINT_PRIORITY20 #define UART0INT_PRIORITY15 [...] NVIC_SetPriority(UART0_IRQn, UART0INT_PRIORITY);//((0x01<<3)|0x01)); NVIC_EnableIRQ(UART0_IRQn); [...] NVIC_SetPriority(RIT_IRQn, RITINT_PRIORITY); NVIC_EnableIRQ(RIT_IRQn); |