FreeRTOS Support Archive

The FreeRTOS support forum can be used for active support both from Amazon Web Services
and the community. In return for using our software for
free, we request you play fair and do your bit to help others! Sign up
to receive notifications of new support topics then help where you can.

This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.

machine resetting with two tasks PIC24 family

If I have one task (flash the led) it runs fine. But if I add two tasks (led and uart) the machine resets at PC zero. I set a breakpoint in the function void vTaskIncrementTick( void ) and watch the xTickCount variable.

What happens, I start the machine running it increments the xTickCount to 2 and then resets the PC down to zero and starts all over again.

I took the standard project got it running on the demo board and stripped it down the simplest form: (croutine.c, heap_1.c, list.c, port.c, portasm_PIC24.S, queue.c, tasks.c, FreeRTOSConfig.h) I have added two additional files main.c and uart.c.

So there is something I missing in my setup to get the scheduler to run properly and being able to switch between tasks.

RE: machine resetting with two tasks PIC24 family

At the suggestion of the UART I went and disable the UART code. It's really a loop to dump a character to the UART to test that the port is writing and I had not enabled the interrupts. So I changed the task code to turn on the LED in my UART task and turn off the LED in the led Flash task. I am not addressing the UART port at all this code.

When I run two tasks, the machine does reset and the PC does reset to zero. I am using a PIC24F16KA102. I had a similar post that the task counter was not incrementing.

I have gone back in the code I can see TMR1 being set as the TASK interrupt.

I think in moving the code over for this chip, I don't have everything configured correctly so the task management is not working correctly. Any other ideas?

RE: machine resetting with two tasks PIC24 family

I went and removed all my UART related code, then I added a second LED to flash in my 2nd flash task. I built the code using one task switching between the two tasks and both versions work correctly. The LED flash delay is different in the two tasks.

I enable both tasks at the same time, neither one works correctly together.

Now I have configured the task to use a small stack: #define configMINIMAL_STACK_SIZE( 24 )So it must be the way the machine is setup in the config or the port.

RE: machine resetting with two tasks PIC24 family

I've just looked at the demo for the PIC24 and configMINIMAL_STACK_SIZE is set to 115. I should not set it lower than that. I would expect and almost immediate crash with it set to 24 (unless you have stack checking switched on, in which case I would expect the stack check to almost immediately flag an error).

Regards.

RE: machine resetting with two tasks PIC24 family

Richard and All, I appreciate the help. The stack size was too small. I moved it back to the original 115 ( I had moved it smaller because of a compile issue) and my heap back to 1024. It works correctly. This is also the same root cause of why I was not getting the DelayUntil function working.