FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! 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.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [October 2008 Threads] simple application on MPC5516Posted by SimFr on October 6, 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; } }
RE: simple application on MPC5516Posted by woops_ on October 6, 2008 Did you try the normal flash tasks that come in the zip? Also step the code to see what values are calculated for the delays.
RE: simple application on MPC5516Posted by SimFr on October 7, 2008 Thank you for your answer!
The values, which are calculated for the delays are the right ones for each task.
I saw, that the values for xLastFlashTime are not updated each time vTaskDelayUntil is called. What could be the cause for this problem?
RE: simple application on MPC5516Posted by Richard on October 8, 2008 I think this should only be the case if xFlashRate was set to 0. Try stepping through the call to vTaskDelayUntil() to see what happens to the value.
Regards.
RE: simple application on MPC5516Posted by SimFr on October 11, 2008 Thank you very much for your answer. I will try stepping through the code.
Best regards,
SimFr
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|