I have a system which is running fine with 2 tasks and 2 timers with FreeRTOS 7.4.0 on a Cortex-M3 (Energy Micro EFM32LG232). Compiler is GNU Tools ARM Embedded 4.7 2012q4. Tickless idle has been enabled and is implemented using the on-chip RTC.
I have added new module which uses another timer, and now the system is beginning to Hard Fault straight away from OS start.
I have commented out as much code as I can, but it appears to be the call to xTimerCreate (which happens before OS Startup) which makes all the difference. Even if the timer is never started, the micro will hit a hard fault after the OS is started. Commenting out the new call to xTimerCreate stops the hard fault from occurring.
The HardFault handler from http://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html has been copied in.
When the hard fault occurs,
- The “Tmr Svc” task is running (according to the Task Table in Eclipse)
- HFSR.FORCED = 1 (all other bits 0)
- CFSR.INVSTATE = 1 (all other bits 0)
- The stacks do not appear to have overflowed as there is plenty of space filled with the poison value.
- pulFaultStackAddress = 0x20007fc0
- stacked_r0 = 0
- stacked_r1 = 0
- stacked_r2 = 0x10000000
- stacked_r3 = 0xE000ED04
- stacked_r12 = 0xA5A5A5A5
- stacked_lr = 0xFFFFFFFD
- stacked_pc = 0xbe00 (no instructions here, it is all 0xFF)
- stacked_psr = 0x6000000E (PendSV ISR active?)
I have analysed the memory contents before and after the call to xTimerCreate and nothing there appears to be writing anything where it shouldn’t.
Not sure what is going on here. Funny thing is that the error that causes the hard fault looks like it is coming from the SVC Handler ISR.
I hope that someone else here who has used the CM3 with Timers on FreeRTOS can make some suggestions. Many thanks!