My first attempt at using FreeRTOS went smoothly with an 18F8723. My second attempt is a little bumpy. I am attempting to port a 18F2620. In this design I use all of the CCP modules, so I am attempting to use timer 0 for the timer tick resource. After having the initial problems, I went back to the 8723 and changed the existing method of using a compare module and timer for the timer tick to only using timer 0, and successfully.
What seems to be happening is that any of the task delays seem to return immediately. Time slicing with 2 tasks seem to be working. I have a test point toggling on in the timer tick routine as well as both of the test tasks. I thought that there is a problem updating the timer tick counter, but I wrote a small routine that fetches the variable, and it is counting.
What would be some of the next steps in debugging this issue?
Are you using calls to vTaskDelayUntil()? If so, are you initialising the first parameter before using it for the first time? It should be initialised to the current time before it gets used, but once its initialised you should not (normally) write to it directly again.
I believe so:
static void vHeartBeat( void *pvParameters )
xDelayTime = xTaskGetTickCount();
for( ;; )
vTaskDelayUntil (&xDelayTime, DELAY_SEC);
LED1 = !LED1;
And I toggle another testpoint in the timer tick routine:
static void prvTickISR( void )
/* Interrupts must have been enabled for the ISR to fire, so we have to
save the context with interrupts enabled. */
INTCONbits.TMR0IF = 0;
TMR0H = ( unsigned char ) 0x82;
TMR0L = ( unsigned char ) 0xff;
portSAVE_CONTEXT( portGLOBAL_INTERRUPT_FLAG );
/* Maintain the tick count. */
#if configUSE_PREEMPTION == 1
/* Switch to the highest priority task that is ready to run. */
I am expecting LED1 to toggle at a 1 second rate, but it toggles faster than TP3.