Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists