simfr wrote on Monday, October 06, 2008:
Hello,
I ported the FreeRTOS to the Freescale MPC5516. FreeRTOS seems to run so far. For a proof-of-concept, I set up an application, where three tasks toggle three LEDs - each tasks toggles "its" LED with a specific frequency.
The problem is, that - when running the application - all three LEDS are toggled exactly the same time with the same frequency. Can somebody help me please? I think I did something wrong in the portTASK_FUNCTION (please see end of message for sourcecode). If not, what could I have done wrong else?
Thank you very much in advance.
Best regards
SimFr
*******************************************************************
static portTASK_FUNCTION( vLEDFlashTask, pvParameters )
{
portTickType xFlashRate, xLastFlashTime;
unsigned portBASE_TYPE uxLED, bit_Mask;
/* The parameters are not used. */
( void ) pvParameters;
/* Calculate the LED and flash rate. */
portENTER_CRITICAL();
{
/* See which of the eight LED’s we should use. */
uxLED = uxFlashTaskNumber;
/* Update so the next task uses the next LED. */
uxFlashTaskNumber++;
}
portEXIT_CRITICAL();
/* Determine the Bitmask for each of the three tasks */
if (uxLED == 0) bit_Mask = 0x80000000;
else if (uxLED == 1) bit_Mask = 0x40000000;
else if (uxLED == 2) bit_Mask = 0x20000000;
/* Determine the Flash rate for each of the three tasks */
xFlashRate = ledFLASH_RATE_BASE + ( ledFLASH_RATE_BASE * ( portTickType ) ( uxLED ));
xFlashRate /= portTICK_RATE_MS;
/* We will turn the LED on and off again in the delay period, so each
delay is only half the total period. */
xFlashRate /= ( portTickType ) 2;
/* We need to initialise xLastFlashTime prior to the first call to
vTaskDelayUntil(). */
xLastFlashTime = xTaskGetTickCount();
/* Turn LED off for checking reason */
SIU.PGPDO1.R ^= bit_Mask;
for(;
{
/* Delay for half the flash period then turn the LED on - specific for each task. */
vTaskDelayUntil( &xLastFlashTime, xFlashRate );
SIU.PGPDO1.R ^= bit_Mask;
/* Delay for half the flash period then turn the LED off - specific for each task. */
vTaskDelayUntil( &xLastFlashTime, xFlashRate );
SIU.PGPDO1.R ^= bit_Mask;
}
}