I’m using the latest FreeRTOS version 7.4.2 and after a short while when vTaskDelay(250) is called I get a “Hard Fault” error.
Following the vTaskDelay function (where INCLUDE_vTaskDelay has been set to ‘1’), I see that portYIELD_WITHIN_API() calls vPortYield where portNVIC_INT_CTRL_REG (Interrupt Control State Register at 0xe000ed04) PENDSVSET bit is set causing a PendSV interrupt.
The vPortSVCHandler calls the vTaskSwitchContex function .
So far all is well and this function returns to the vPortSVCHandler.
However at the end of vPortSVCHandler, the “lr” register is set to 0xfffffffd such that the last instruction “bx lr”, not surprisingly, causes a Hard Fault interrupt. GDB gives me:
3 HardFaultHandler() main.c 0x8000210
2 <symbol is not available > 0xfffffffc
1 <symbol is not available > 0xfffffffc
This address is consistent with the “bx lr” instruction for Thumb code (LSB set to ‘1’)
Can anyone give me a clue to what’s going on?