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 :)