We are using Apollo3 STIMER for FreeRTOS9 scheduling and there is FreeRTOS hang up issue in some rare cases. After the investigation, we find FreeRTOS hang up is caused by that STIMER interrupt is not triggered while STIMER counter value is greater than its compare register value. Why is there no STIMER interrupt in this case?
It is possible that there is a clock glitch which may cause STIMER double count so that its interrupt is lost. STIMER supports multiple comparators. Currently CMPA is used. One solution is to use another comparator CMPB as a backup. If the STIMER double counts, then CMPA will not see it, but CMPB will see it immediately by setting CMPB one count higher than CMPA. To solve the FreeRTOS hang up issue, please use following C file to replace FreeRTOS9\Source\portable\Keil\AMapollo2\port.c in your environment. It can be used for KEIL directly and it can also be ported to IAR and GCC.
The workaround we recommend is therefore to set a second "backup" compare that has a value that is 1 larger than the desired compare. Then, if a glitch causes a double count over the desired compare, it will hit the backup compare.