USB to RS232 switch

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all,

I’m trying to make some kind of switch between a USB-UART single chip bridge (Silicon Labs CP2102) and the two USART’s on a ATmega128 board.

First I’ll explain the configuration: I have on one side a PC which is connected via the USB-UART chip to the UART1 on the ATmega128 board. UART0 from the ATmega128 board is connected via a RS232 level shifter to the RS232 port on another third party controller board.

When the controller board is running in normal mode, it streams data to the ATmega128 board, which logs this data into memory. From the PC I can then upload this data from the ATmega128 board, this part works ok.

Now the problem, that third party controller board is also configurable via a PC program. But that controller board has only a RS232 port, no USB. So what I’m trying to do is to connect the controller board via the ATmega128 board to the PC via USB (some kind of bridge or gateway).

So first I tried to ‘bridge’ the two USART’s from the ATmega128 board, with the respective rx- interrupts from the USART’s. So when USART1 receives a byte from the USB-USART chip(the PC program), it then transmit it on USART0 (connected to the controller board). When USART0 receives a byte from the controller board, it then transmit it to the USB-USART chip back to the PC program.

Strangely enough it works, but not 100%, some functions do not work, but most does.
I tried to bit bang the UART ports, but that did not work.

So what are my options?
Is there a special configuration for the USART's in the ATmega128 that could do that?

Or will I need to hardwire the USB chip directly to the RS232 level shifter on the ATmega128 board, with some kind of a latch, and disable the UART’s when I want to connect directly?

Sounds crazy I know :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My guess is the functions that do not work probably are toggled by RTS or DTR, which in your case are not being routed through to the board... Just a guess though...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you mean by hardware handshaking?
I don’t think it’s that, there’s no hardware handshaking configuration needed on the COM port.

My guess is that the PC communication software uses some kind of pull high or low on rx or tx, for some period, then waiting on a response from the controller board to pull that line to the opposite level , I’m not a RS232 specialist, just started learning a bit deeper into it.

Anyone have some suggestions?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe you are clearing an interrupt unintentionally.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well it's probably the controller board that drives the rx-line to -9V when it's powered, that is checked by the PC program to start communication, and I'm afraid I can't simulate that with the USB-UART bridge that I have(CP2102).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

UNiXWHoRe wrote:
My guess is the functions that do not work probably are toggled by RTS or DTR, which in your case are not being routed through to the board... Just a guess though...

I know it's a little late, but you where absolutely right about that, the DTR line is toggled first by the application, this makes the device to toggle the DCD line and then wait on commands to respond to, the application only starts to send out commands when the DCD line is toggled.

But I have another question, which USB-RS232 bridge would you guy’s recommend, those from FTDI or the one’s from Silab? I am asking as I need to make a decision for the pcb board layout. I’ll ask it on the electronics forum also, but wanted to respond to this topic anyway.

Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
those from FTDI or the one’s from Silab

Don't forget Prolific too (http://www.prolific.com.tw/eng/Products.asp?ID=59). But I think most people here find the FTDI's most satisfying.

Cliff