I’m having problems with FreeRTOS periodically reseting for no apparent reason. Even running the demo project contained in the FreeRTOS distribution shows the same problem. It will run for an hour or two and then the debugger halts showing “No user code at 0x0”
I’m using MPLAB X IDE v2.15, xc16-gcc v1.21 and ICD 3 with a dsPIC33FJ256GP710A on the Microchip Explorer 16 board. FreeRTOS version is 8.1.2.
I picked up the documentation package and ported the very simple two task example from the “Using the FreeRTOS Real Time Kernel – A Practical Guide” PIC32 edition and it shows the same reset problem after running for a while.
I’ve identified that it isn’t my hardware or MPLAB environment as the Microchip Explorer 16 demo ran for close to a day without a reset.
I added the interrupt trap file from the Explorer 16 demo which has system interrupt traps with infinite while loops for the things that cause a processor reset (E.g. address, stack, math errors) but none of the interrupts are entered when the FreeRTOS application halts.
I’ve ensured the project has the MPLAB
DSPICPORT definition defined in the pre processing and messages “Define C macrons” option as I saw a post that indicated the author’s resets were due to the lack of this definition.
The problem can be replicated by simply running the FreeRTOS dsPIC demo application for a while with the debugger on. You’ll find eventually the session halts.
Here is the configuration and source for the simple ported FreeRTOS that is the simplest I’ve been able to setup to replicate the problem based on the initial task logic from the FreeRTOS documentation.
Start this up with the debugger and after a few hours you’ll find the session halted and a message indicating no source code at PC 0x0:
~~~~~~~~~~~~~~~~~~~
define configUSE_PREEMPTION 1
define configUSEIDLEHOOK 1
define configUSETICKHOOK 0
define configTICKRATEHZ ( ( TickType_t ) 1000 )
define configCPUCLOCKHZ ( ( unsigned long ) 25000000 ) /* Fosc / 2 */
define configMAX_PRIORITIES ( 4 )
define configMINIMALSTACKSIZE ( 240 )
define configTOTALHEAPSIZE ( ( size_t ) 10240 )
define configMAXTASKNAME_LEN ( 5 )
define configUSETRACEFACILITY 0
define configUSE16BIT_TICKS 1
define configIDLESHOULDYIELD 1
define configCHECKFORSTACK_OVERFLOW 1
/* Co-routine definitions. */
define configUSECOROUTINES 0
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
define INCLUDE_vTaskPrioritySet 1
define INCLUDE_uxTaskPriorityGet 0
define INCLUDE_vTaskDelete 0
define INCLUDE_vTaskCleanUpResources 0
define INCLUDE_vTaskSuspend 1
define INCLUDE_vTaskDelayUntil 1
define INCLUDE_vTaskDelay 1
define configKERNELINTERRUPTPRIORITY 0x01
~~~~~~~~~~~~~~~~~~~~~~~~
and the main.c:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*
* File: main.c
* Author: cwelch
*
* Created on September 24, 2014, 9:55 PM
*/
include <stdio.h>
include <stdlib.h>
include “FreeRTOS.h”
include “task.h”
define mainDELAYLOOPCOUNT (0xfffff)
/
———————————————————–/
void vApplicationIdleHook( void )
{
;
}
/
———————————————————–/
void vTask1(void *pvParameter)
{
// const char *pcTaskName = “Task 2 is runningn”;
volatile unsigned long ul;
while(1)
{
for (ul = 0; ul < mainDELAY_LOOP_COUNT; ul++)
{
;
}
}
}
void vTask2(void *pvParameter)
{
// const char *pcTaskName = “Task 2 is runningn”;
volatile unsigned long ul;
while(1)
{
for (ul = 0; ul < mainDELAY_LOOP_COUNT; ul++)
{
;
}
}
}
/*
*
*/
int main(int argc, char** argv)
{
//vTask1();
xTaskCreate(vTask1, "TSK1", 240, NULL, 1, NULL);
xTaskCreate(vTask2, "TSK2", 240, NULL, 1, NULL);
// Should run for ever after this
vTaskStartScheduler();
// Will only reach here if there is insufficient heap available to start the scheduler.
return (EXIT_FAILURE);
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I have most of my application now working under FreeRTOS, but need to address this last problem of stability. It is an engine controller and I can’t have it spontaneously resetting.
Thanks in advance for your assistance!
Chris
~~~~~~~~~~~~~~~~~~~~~~~~~~~