Hello,
I wrote FreeRTOS code for blinking LED on STM32F103RB. When i debug the program it goes into HardFault exception. May i know what is the exact cause of this.
May i know what is the exact cause of this.
You may. Use the debugger and find the point where the HardFault is triggered.
Peripherals->Core peripherals->Fault reports
I have a delay function in while loop. When this delay function is executing it goes to void xPortSysTickHandler( void ), it executes few instructions, then it goes to __asm void vPortSetInterruptMask( void )
{ PRESERVE8
push { r0 } mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY msr basepri, r0 pop { r0 } bx r14 }
it executes this then void vTaskIncrementTick( void ) is done. then it goes to
__asm void vPortClearInterruptMask( void )
push { r0 } mov r0, #0 msr basepri, r0 pop { r0 } bx r14 } then it goes to
__asm void xPortPendSVHandler( void )
{ extern uxCriticalNesting; extern pxCurrentTCB; extern vTaskSwitchContext;
PRESERVE8
-----> mrs r0, psp
ldr r3, =pxCurrentTCB /* Get the location of the current TCB. */ ldr r2, [r3]
stmdb r0!, {r4-r11} /* Save the remaining registers. */ str r0, [r2] /* Save the new top of stack into the first member of the TCB. */
stmdb sp!, {r3, r14} mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY msr basepri, r0 bl vTaskSwitchContext mov r0, #0 msr basepri, r0 ldmia sp!, {r3, r14}
ldr r1, [r3] ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. */ ldmia r0!, {r4-r11} /* Pop the registers and the critical nesting count. */ msr psp, r0 bx r14
nop }
i have show arrow in above code, from that is executes. When it executes nop instruction at last it jumps to Hardfault exception.
i guess while poping it is going to some different location.
Do help me out please
May i know sir what do you mean by Peripherals->Core peripherals->Fault reports?
Is it that i have initialized GPIO pins so it is giving error?
Look at uv4's menu bar and you'll get it. And yet, maybe your GPIO block is not powered. That can lead to a hard fault.
Peripherals->Core peripherals->Fault reports? i checked in bar menu. in that HARD_FAULT_STAT: 0x40000000 and forced option is ticked when i debug. Should i make it zero? what does this mean?
Should i make it zero?
NO !
what does this mean?
Read a cortex M3 architecture document and your chip's user manual.
Sir what changes should i make to resolve my error. My GPIO is set properly when i check in debug. please do help
please do help
How can I? I am not telepathic. I would argue that no one here is. Debug it -> solve it.
Have you made sure you don't have a stack overflow, and don't have a memory overrun, and don't make use of any uninitialized pointers or index variables?
After all - debugging is a significant part of programming.
thank u all.. finally it worked... have to do few changes in freertos code..
have to do few changes in freertos code..
Probably the wrong solution, unless it is a change to the ported code !
Its not wrong.. did one change in port.c file