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

QueueSend from two tasks

Posted by Jörg Krein on February 7, 2006
Hi,

when trying to write in a message queue from two tasks I get stuck in the undefined handler.
I'm using ARM STR7 with gcc. I redirected the _write() function of newlib to my putchar function. I writes in a queue from where the tx-empty isr reads.
When only one tasks uses iprintf it works.
Nonpreemption doesn't work also.
I did work in my Atmega128 port!

In main.c I wrote:

void LEDTask1( void *pvParameters )
{
while(1)
{
iprintf( "Task1\r\n" );
vTaskDelay( 500/portTICK_RATE_MS );
}
}

void LEDTask2( void *pvParameters )
{
while(1)
{
iprintf( "Task2\r\n" );
vTaskDelay( 1000/portTICK_RATE_MS );
}
}

In uart0.c I wrote:

void uart0_isr( void ) __attribute__((interrupt("IRQ")));
void uart0_isr( void )
{
// portENTER_SWITCHING_ISR();
char chr;
portBASE_TYPE TaskWokenByRec = pdFALSE;

if( UART0_SR & UART_TXHALFEMPTY )
{
if( xQueueReceiveFromISR( QueSer0Tx, &chr, &TaskWokenByRec ) == pdTRUE )
{
UART0_TxBUFR = chr;
}
else
{
UART0_IER &= ~UART_TXHALFEMPTY;
}
}
EIC_IPR0 = CHANNEL(9);

//portEXIT_SWITCHING_ISR( TaskWokenByRec );
//portEXIT_SWITCHING_ISR( 0 );
}

Any hints?

RE: QueueSend from two tasks

Posted by Nobody/Anonymous on February 7, 2006
Am I right in thinking from your description that the queue send is in the iprintf - and writes to QueSer0Tx.

How much stack does your iprintf function use. Traditionally printf functions can be very stack hungry. Have you checked that you are not running off the end of the task stack? Try making the stack a bit larger or checking it once you enter the undefined handler.

Which interrupt fires to end up in the undefined handler - any or are you just jumping to a random place in the code.

RE: QueueSend from two tasks

Posted by Jörg Krein on February 8, 2006
Hi,
the problem lies in the too small configTOTAL_HEAP_SIZE.
If I do:
xTaskCreate( LEDTask2, "LED2", configMINIMAL_STACK_SIZE + 300, NULL, tskIDLE_PRIORITY+1, NULL );
for two tasks and heap size of 1000 it chrashes.
I had to set it to about 5000, without printf!
I wonder how 2 * 300 + 2 * 110 (minimal stack size)
needs more than 5000 bytes?
The createTask and malloc functions returned without error.

Regards,

RE: QueueSend from two tasks

Posted by Nobody/Anonymous on February 8, 2006
Sounds suspicious. I think you should analyse the memory usage of your system. Do you have a decent debugger?

RE: QueueSend from two tasks

Posted by Nobody/Anonymous on February 9, 2006
Hi,
yes I have a decent debugger.
It showed me that the size of the task stack is in words = 4 bytes!

pxNewTCB->pxStack = ( portSTACK_TYPE * ) pvPortMalloc( ( ( size_t )usStackDepth ) * sizeof( portSTACK_TYPE ) );

portSTACK_TYPE is defined as long in the ARM7 ports. Whereas in heap1.c :

unsigned portCHAR ucHeap[ configTOTAL_HEAP_SIZE ];

the heap is defined in bytes (portCHAR).

Ok, one has to know.
Maybe you could equal this Richard?
Regards,



RE: QueueSend from two tasks

Posted by Richard on February 10, 2006
I'm can't quite follow this thread. What is the issue? The stack depth is given by the usStackDepth parameter. As per the documentation this is the number of items that can be on the stack - not the number of bytes - hence it is multiplied by sizeof( portSTACK_TYPE ).

Regards.


[ 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