Quality RTOS & Embedded Software

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


using 2 serial ports problem??

Posted by Nobody/Anonymous on January 29, 2007

I have been using STR91x demo board from IAR with FreeRTOS successfully.

I used the serial port driver, using UART 1, provided in the demo and it works fine.

As I was in need of 2 serial ports, I copied the serial port driver, i.e. serial.c, and modified it to use UART 0. But the program just hangs after I call "UART_Init( UART0, &xUART0_Init );".

Few observations on the issue:
-As UART_Init() works with UART0 and is a function in library provided by ST, I beleive it cannot be wrong.
-I rechecked the parameters I am passing to the function and it all seems correct.
-I debugged the program using JTAG and found that just after executing the line "UARTx->LCR &= UART_Parity_Mask;", in function UART_Init() of 91x_uart.c, the program hangs and Jtag also loses the control over the target.

Does anybody have any idea what can be wrong?
Have anybody successfully used 2 serial ports on STR91x board?

Any help will be highly appreciated.

RE: using 2 serial ports problem??

Posted by Richard on January 29, 2007
Is it possible that you have interrupts enabled when you create initialise the UART, causing an interrupt to execute immediately and before the infrastructure required by the ISR (queues, tasks, scheduler, etc.) is ready?

If you take a look at some of the x86 ports you will see how the port parameter of the serial functions are used to permit more than one UART port.


RE: using 2 serial ports problem??

Posted by Nobody/Anonymous on January 29, 2007

Dear Richard,

Thank you for your help.

I also suspect that the problem is memory corruption due to uninitialized environment.

But rather then looking to implement 2 serial ports simultaneously, this time I tried to break up the problem.

I tried using _ONLY_ one serial port based on UART0. I changed the serial.c to use UART0 instead of UART1. It was just changing all instances of structure UART1 to UART0, as the internal register and bit definitions are identical for UART1 and UART0. And changing the interrupt service routine to UART0 from UART1.

But this time also, the result was same. After calling "UART_Init( UART0, &xUART0_Init );" everything stops. And if I use JTAG then it just halts at "__DebugBreak" i.e the breakpoint instruction.

What can be the problem for this behavior?

What are the possible places of mistakes which can led to such problem??

RE: using 2 serial ports problem??

Posted by Dave S on June 16, 2008
I'm also having a similar problem when using 2 com ports.
Using one or the other COM port alone works fine, but when I try to use them both simultaneously the code gets stuck in IRQHandler() in 91x_vect_IAR.s. It seems to occur when I first send on COM1, then COM2, then back to COM1.

I modified the serial.c example for the STR9 to use 2 COM ports.
I created a structure similar to the one in the x86 demo:

typedef struct {
xQueueHandle xRxedChars;
xSemaphoreHandle xTxFIFOSemaphore;
portLONG lTaskWaiting;
} portHANDLE;

There's a separate instance of the structure for each com port.

Did I missing something?


RE: using 2 serial ports problem??

Posted by Kevin Cho on April 24, 2009
I got the same problem...

In my case, I have to use 3 serial port on STR910-eval board.

Is there any example code for using more than one serial port on STR910-eval.


RE: using 2 serial ports problem??

Posted by Kevin Cho on April 24, 2009

I've solved this problem.

Actually it's not problem.
It's my mistake...

/************************* UART ************************/
#define _UART
#define _UART0
#define _UART1
#define _UART2

Just uncomment these macros in "at91x_conf.h".

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

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

Latest News

Version 10.1.0 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.


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


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