I have been having problems with scheduler running properly.
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.
I have disable the watchdog timers and brown-out resets.
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?
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.
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).
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.