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


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