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

xQueueReceive program block

Posted by dudisor on December 3, 2013

Hi all,

I'm new to FreeRTOS. Try to use version 7.6.0 ported to atmega128 atxmega128A1 and CodevisionAVR. The demo does not work. I managed to reduce the problem to a simple program:

When creating a reading queue task, the program fails, the LEDs stop flashing. Without reading queue task, the led4 flashes 5 times and then stops because the queue is full and led0 toggle every 1 sec.

If I set priority 0 for the task vReadQueue, led4 and led5 light up and stay lit and led0 not flashes. Timer intrerrupt is triggering, and program is stuck in file list.c, function: void vListInsert( xList * const pxList, xListItem * const pxNewListItem ) in the for loop.

~~~~~~

	for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 The mini list structure is used as the list end to save RAM.  This is checked and valid. */
	{
		/* There is nothing to do here, we are just iterating to the
		wanted insertion position. */

                // here it loops forever

	}

~~~~~~~

I tried demo port AVRATMega323WinAVR modified for ATmega128 and WinAVR and it does not work to.

~~~~~~

define mainLEDTASKPRIORITY 1
define mainTESTQUEUEPRIORITY 2
define mainTIMP0 ( portTickType ) 1000 / portTICKRATEMS
define mainTIMPQWRITE ( portTickType ) 500 / portTICKRATEMS
define mainTIMPQREAD ( portTickType ) 0xffff
define mainNO_DELAY ( portTickType ) 0

//definitii prototipuri static void vLed0( void *pvParameters );

void vWriteQueue( void *pvParameters ); void vReadQueue( void *pvParameters ); void setTestQueue(char prioritate);

static xQueueHandle xCoada; //xSemaphoreHandle xSemaphore;

void main(void) { vParTestInitialise();

/* Create the tasks defined within this file. */

xTaskCreate( vLed0, ( signed char * )"led0", configMINIMALSTACKSIZE, NULL, mainLEDTASKPRIORITY, NULL );

//vStartPolledQueueTasks( mainQUEUEPOLLPRIORITY ); //vAltStartComTestTasks( mainCOMTESTPRIORITY, 38400, led6 );

setTestQueue(mainTESTQUEUEPRIORITY);

vTaskStartScheduler();

while (1) { ; //nu trebuie sa ajunga aici; } }

void setTestQueue(char prioritate) { xCoada=xQueueCreate(5, sizeof(char)); //xSemaphore=xSemaphoreCreateBinary();

xTaskCreate( vWriteQueue, ( signed char * ) "QProdNB", configMINIMALSTACKSIZE, NULL, prioritate - 1, ( xTaskHandle * ) NULL );

/* -- next task, if it is created, block all program -- / xTaskCreate( vReadQueue, ( signed char * ) "QConsNB", configMINIMALSTACKSIZE, NULL, prioritate, ( xTaskHandle * ) NULL ); / --------------------------- */ }

void vWriteQueue( void *pvParameters ) { portTickType xLastWakeTime; char c=0; // Initialise the xLastWakeTime variable with the current time. xLastWakeTime = xTaskGetTickCount();

for( ;; ) { c++;
//if( xSemaphoreGive( xSemaphore ) == pdPASS ) if( xQueueSend(xCoada, &c, mainNODELAY ) == pdPASS ) { vParTestToggleLED(led4); } vTaskDelayUntil( &xLastWakeTime, ( portTickType ) 333 / portTICKRATE_MS );
} }

void vReadQueue( void *pvParameters ) { char c=0; for( ;; ) { //if( xSemaphoreTake( xSemaphore, ( portTickType ) 10 / portTICKRATEMS ) == pdPASS ) if( xQueueReceive(xCoada, &c, portMAX_DELAY ) == pdPASS ) // <-- Here get stuck { vParTestToggleLED(led5); } } }

static void vLed0( void *pvParameters ) { portTickType xLastWakeTime;

// Initialise the xLastWakeTime variable with the current time. xLastWakeTime = xTaskGetTickCount();

for( ;; ) { vTaskDelayUntil( &xLastWakeTime, mainTIMP0 );
vParTestToggleLED(led0); } } ~~~~~~~

my FreeRTOSconfig.h file:

~~~~~~~~ /* Call stack size for 1 task */

define configCALLSTACKSIZE 32
define configUSE_PREEMPTION 1
define configUSEPORTOPTIMISEDTASKSELECTION 0
define configUSETICKLESSIDLE 0
define configCPUCLOCKHZ ( ( unsigned portLONG ) 14745600 )
define configTICKRATEHZ ( ( portTickType ) 250 )
define configMAXPRIORITIES ( ( unsigned portBASETYPE ) 4 )
define configMINIMALSTACKSIZE ( ( unsigned portSHORT ) 65 + configCALLSTACKSIZE )
define configTOTALHEAPSIZE ( (size_t ) ( 1500 ) )
define configMAXTASKNAME_LEN ( 8 )
define configUSE16BIT_TICKS 1
define configIDLESHOULDYIELD 1
define configUSE_MUTEXES 0
define configUSERECURSIVEMUTEXES 0
define configUSECOUNTINGSEMAPHORES 0
define configQUEUEREGISTRYSIZE 10
define configUSEQUEUESETS 0
define configUSETIMESLICING 1
define configUSENEWLIBREENTRANT 0

/* Co-routine definitions. */

define configUSECOROUTINES 0
define configMAXCOROUTINE_PRIORITIES ( 2 )

/* Hook function related definitions. */

define configUSEIDLEHOOK 0
define configUSETICKHOOK 0
define configCHECKFORSTACK_OVERFLOW 0
define configUSEMALLOCFAILED_HOOK 0

/* Run time and task stats gathering related definitions. */

define configGENERATERUNTIME_STATS 0
define configUSETRACEFACILITY 0
define configUSESTATSFORMATTING_FUNCTIONS 0

/* Software timer related definitions. */

define configUSE_TIMERS 0
define configTIMERTASKPRIORITY 3
define configTIMERQUEUELENGTH 10
define configTIMERTASKSTACKDEPTH configMINIMALSTACK_SIZE

/* Interrupt nesting behaviour configuration. */

define configKERNELINTERRUPTPRIORITY 3
define configMAXSYSCALLINTERRUPT_PRIORITY 3
define configMAXAPICALLINTERRUPTPRIORITY 3

/* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */

/* Optional functions - most linkers will remove unused functions anyway. */

define INCLUDE_vTaskPrioritySet 1
define INCLUDE_uxTaskPriorityGet 1
define INCLUDE_vTaskDelete 1
define INCLUDE_vTaskSuspend 0
define INCLUDE_xResumeFromISR 0
define INCLUDE_vTaskDelayUntil 1
define INCLUDE_vTaskDelay 1
define INCLUDE_xTaskGetSchedulerState 0
define INCLUDE_xTaskGetCurrentTaskHandle 0
define INCLUDE_uxTaskGetStackHighWaterMark 0
define INCLUDE_xTaskGetIdleTaskHandle 0
define INCLUDE_xTimerGetTimerDaemonTaskHandle 0
define INCLUDE_pcTaskGetTaskName 0
define INCLUDE_eTaskGetState 0

~~~~~~~~

Any help is appreciated.

Thanks in advance, Adrian


xQueueReceive program block

Posted by richardbarry on December 3, 2013

Note there is no official XMega port (there is an AVR and a MegaAVR, but not an XMega), so the first thing to ask is, where did you get the code from?

If you wrote it yourself or obtained it from somebody else then it is difficult for us to support you directly. There are however some XMega ports in the FreeRTOS Interactive site, which is where contributed code lives: http://interactive.freertos.org if you got the code from there then it is possible the contributor will be able to help you.

If on the other hand you are trying to use the AVR or MegaAVR code from the FreeRTOS distribution, then that is not going to work on an XMega part.

Regards.


xQueueReceive program block

Posted by dudisor on December 3, 2013

Sorry, I meant ATmega128.

I try to port also on atxmega128A and I mistyped.


[ 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