alsaleem wrote on Monday, July 10, 2017:
Hi,
I have an application that runs for several hours then stops at the default handler.
My code is running repeatedly so there is no new code introduced at the fault time.
I am using STM32F411 with (FreeRTOS V8.2.1)
I am using the code presented here in RTOS site, repeated down:
.section .text.Default_Handler,"ax",%progbits
Default_Handler:
/* Load the address of the interrupt control register into r3. */
/* NVIC_INT_CTRL_CONST */
/*ldr r3, #0xE000ED04 */
ldr r3, =SCBICSR
/* Load the value of the interrupt control register into r2 from the address held in r3. */
ldr r2, [r3, #0]
/* The interrupt number is in the least significant byte - clear all other bits. */
uxtb r2, r2
Infinite_Loop:
b Infinite_Loop (<====)
.size Default_Handler, .-Default_Handler
R2 indeed has the value of (3), PC is pointing to (b Infinite_Loop)
I also implemeted the other code for hard fault handler with C function (hard_fault_handler_c) to print variables, but nothing was printed.
.section .text.HardFault_Handler
.weak HardFault_Handler
.type HardFault_Handler, %function
HardFault_Handler:
TST LR, #4
ITE EQ
MRSEQ R0, MSP
MRSNE R0, PSP
B hard_fault_handler_c
.size HardFault_Handler, .-HardFault_Handler
The vector table is arranged as :
g_pfnVectors:
.word _estack
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
.word MemManage_Handler
.word BusFault_Handler
....
....
The hard fault handler is defined as
.weak HardFault_Handler
.thumb_set HardFault_Handler,Default_Handler
I’ve also impleneted the stack overflow function hooks, and also nothing was printed.
void vApplicationMallocFailedHook( void ) {
printf("malloc failed -----------------------------------------------\n");
}
void vApplicationStackOverflowHook( TaskHandle_t xTask, signed char *pcTaskName )
{
printf("stack overflow in task id %lu, name: %s -------------------------------------------\n", (uint32_t)xTask, pcTaskName);
}
So, could some one point where to catch the code that caused the interrupt and why hard_fault interrupt is not being served?
Thanks.