FreeRTOS resets dsPIC30F

faberfred wrote on Monday, March 16, 2009:

Hello everybody,
I need help with the FreeRTOS running on a dsPIC30F4013. It is working except of a reset problem. I tried to solve the problem and reduced the application to one task. The task just contains a for-loop which is limited to 9 cycles. After finishing the nine cycles the device is rebooted. But why is it rebooted? Shouldn’t the idle task hold the device in an infinite running state? A software reset seems to be responsible for the reboot (RCONbits.SWR is set to 1). The watchdogtimer is disabled. Please help me solving this problem. It seems to be the FreeRTOS but I have no idea.
Thank you in advance

edwards3 wrote on Monday, March 16, 2009:

The idle task would only run if you other task blocked, unless it is running at the same priority as the idle task. Can you post the code for your task?

faberfred wrote on Tuesday, March 17, 2009:

I tried running the task with the same priority than the idle task but there is no difference.
Here is the code for the task and the initialization of the task:

void StartTaskOne( void )
    xTaskCreate( (pdTASK_CODE) TaskOne, ( signed portCHAR * ) "TaskOne", configMINIMAL_STACK_SIZE*1, NULL, tskIDLE_PRIORITY + 3 , NULL );

void TaskOne (void)
    char i;
    UART_Init();            //Initialize the UART module to communicate with the COM port

    portTickType xLastExecutionTime;

    xLastExecutionTime = xTaskGetTickCount();

    for(i =0;i < 9;i++)
        vTaskDelayUntil( &xLastExecutionTime, 1000 );
        LATDbits.LATD2 = ~ LATDbits.LATD2;

The stack size of the task is 400 Byte. This should be enough. What can cause this (software) reset?
Thank you

davedoors wrote on Tuesday, March 17, 2009:

You cannot exit a task by returning from the function. If you change your for loop to be an infinite loop then it should be ok (provided your UART is not causing a reset). I recommend reading the eBook.

faberfred wrote on Tuesday, March 17, 2009:

Hello Dave,
You are right. This was my mistake. My real application has three tasks with infinite for-loops. I tried to reduce the complexity of my application and ran into this mistake.
The reset was due to UART and ADC interrupts. I don’t know exactly why, but the interrupts caused the reset. When I disabled the interrupts everything was fine. Now I changed the CPU Interrupt Priority Level from 1 (as default) to 0 and everything is ok. Can anybody tell me how the interrupt priority influences the reset of my device?
Thank you very much for your help!