Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

simple application on MPC5516

Posted 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 MPC5516

Posted 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 MPC5516

Posted 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 MPC5516

Posted 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 MPC5516

Posted by SimFr on October 11, 2008
Thank you very much for your answer. I will try stepping through the code.

Best regards,

SimFr


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner