4
\$\begingroup\$

I have a device which provides a USB port. If I attach it to a Windows PC it is recognized as a "CP2103 USB to UART Bridge Controller". According to the device documentation, it should communicate in serial format at 38400bps.

I have to talk to this device with a atmega microcontroller.

Since the USB pinout is different from the serial UART of the uC, firstly I thought I would need a circuit to convert the signals. I found the AVR-CDC project and put on a CDC-232 in order to convert USB (GND, D+, D-, VCC) to RS232 (TX, RX, GND):

enter image description here

To make it I used another atmega328 as uC, flashed with the specific hex, with a 16Mhz crystal instead of the 12Mhz one specified into the diagram.

Then I built another piece of circuit to convert the RS232 signal to TTL: enter image description here

So the signal conversion should be USB -> RS232 -> TTL.

I programmed my uC to send some data to the device and I can follow the signal with the oscilloscope until it enter into the CDC-232, then I lose it. I have no output on pins 4 and 5 of the CDC-232 uC, where I should have a USB signal.

Is my overall approach right? Sould I go on debugging the CDC-232 part or there is something wrong elsewhere?

\$\endgroup\$
2
  • \$\begingroup\$ could you post a photo of your CP2103 device? \$\endgroup\$ – miceuz Jan 31 '13 at 13:16
  • \$\begingroup\$ I'm not 100% sure I understand the question, but the CP2103 is a USB device that expects to connect to a USB host such as a PC, and the link seems to be to be to an AVR project that also operates as a device. I'm fairly sure an AVR won't operate as a host device unless I've missed something with what you're trying to achieve. \$\endgroup\$ – PeterJ Jan 31 '13 at 13:19
3
\$\begingroup\$

If your device shows up as a CP2013 when you plug the device into a computer's USB port, and you want to replace your Computer with an Arduino, then that isn't really easy to do, or generally possible. The methods you mention in the question have to do where the AVR/Arduino is the device, not the Host.

The device already has a USB-UART converter embedded inside it, and only shows you the USB side of it. This means that your arduino needs to function as a USB host. Functioning as USB host is not straightforward. You need to set up a USB Host/Hub controller, and figure out how to handle enough of the USB protocol stack to talk to the CDC compatible USB-UART device. Using a USB OTG Host controller may be marginally easier, but still nowhere close to being trivially easy. Your best bet would be to see if you can bypass the CP2013 on the device and access the UART lines directly. This may not always be possible. If the CP2013 is actually some other piece of hardware or firmware masquerading as a CP2013, then you're fresh out of luck.

\$\endgroup\$
4
  • \$\begingroup\$ +1 That's what I was getting at with my comment but that's a good clear explanation. \$\endgroup\$ – PeterJ Jan 31 '13 at 13:26
  • \$\begingroup\$ Thank you, I feared it wasn't that simple. Good pointers though. \$\endgroup\$ – etuardu Jan 31 '13 at 14:56
  • \$\begingroup\$ I'm marking your answer as right altough the thing is not resolved. I think I'll use a MAX3421E or a FTDI VNC1L to implement a USB host handled by the avr. \$\endgroup\$ – etuardu Jan 31 '13 at 16:59
  • \$\begingroup\$ Compare the pricing of the device and those adapters - if the device isn't worth hundreds of dollars, I'd look inside. If you are lucky the signals to the CP2103 go through surface mount resistors making them easy to tap. If you do go the embedded USB host route, compare the cost of more modern boards with native USB host functionality to that of an ATMEGA + host adapter. \$\endgroup\$ – Chris Stratton Mar 17 '13 at 16:48
1
\$\begingroup\$

CP2103 is an USB to UART bridge, it talks in TTL levels, you don't need anything extra to communicate with it. You have to hook up the TX, RX, GND pins of microcontroller to RX, TX, GND pins of CP2103 board. Your setup should go like this:

PC --usb-- CP2103 --rx/tx-- MICROCONTROLLER

Setup your microcontroller to output something thru UART and you will be able to see it in a serial communications terminal program on your PC.

\$\endgroup\$
4
  • \$\begingroup\$ It appears they want to go ATmega -> CP2103, because it sounds like the CP2103 end is a peripheral they don't have control over and wish to control from an AVR. \$\endgroup\$ – PeterJ Jan 31 '13 at 14:50
  • \$\begingroup\$ The device I have to talk to expose only a mini USB port, so I don't have any rx/tx \$\endgroup\$ – etuardu Jan 31 '13 at 14:52
  • 1
    \$\begingroup\$ @etuardu, that's what I thought. See what other answers you get but I think what Chintalagiri Shashank said is correct and what you're trying to achieve is somewhere between very difficult and impossible with an AVR. \$\endgroup\$ – PeterJ Jan 31 '13 at 14:57
  • \$\begingroup\$ This is not an answer to the question that was asked. \$\endgroup\$ – Chris Stratton Mar 17 '13 at 16:49
-1
\$\begingroup\$

you need to program cdc full class in your microcontroller first,,,, an before call sei() calling the usbinit() and another usb configuration function .. try again..!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I am not removing this as not an answer, it seems to be an attempt at an answer, although not very clear. @morteza, could you please expand what you mean, looking at the above answers this seems to be way off base. \$\endgroup\$ – Kortuk Mar 17 '13 at 15:58
  • \$\begingroup\$ Sorry, Mortezza, but this has no potential to be an answer, because it overlooks the fact that the necessary USB host interface hardware is missing - something that was established already by the accepted answer. Please delete it before it collects further downvotes. \$\endgroup\$ – Chris Stratton Mar 17 '13 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.