Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

UART to USB Converter

Status
Not open for further replies.
E

expertengr

Guest
I am wondering how to use MCP2221 for UART to USB with microcontroller. I would have UART on the microcontroller side which I would like to connect to MCP2221 to convert the protocol to USB for computer. I guess it's CDC mode but do I need to configure the chip MCP2221 or it's just connecting cables ? and set the virtual COM setting in computer according to Baud rate in microcontroller ?
 

You need to read the MCP2221 data sheet. It shows you how to use the I2C interface to select the BAUD rate for the UART connection to the microcontroller.
On the USB side, there is no such thing as a 'baud rate' in that the CDC protocol handles all of the communications and it is more things like the USB interface is 'full speed' that sets the rate values are exchanged over the USB part of the link.
However the HID part of the MCP2221 can be used to access and control various parts of the device from the computer (USB) side and not just the I2 (microcontroller) size.
By the way, if this is for a new design, I note that Microchip are note recommending that this device be used.
Susan
 

This means MCP2221 will not appear as virtual COM ? I have used an other development board in which there is a bridge on the board for UART to USB, and at the computer side in PuTTY I have to set up serial interface by setting parameters like baud rate, start and stop bit etc but first I have to install a driver for FTDI chip on the computer to get a virtual COM port on the computer.
 

It's quite similar to FTDI devices (or other competitor products), you have to install a driver which provides a virtual COM port.

MCP2221A is the recent production version, b.t.w.
 

I have installed the driver in windows 7 when MCP2221 was connected by USB cable to the computer but I don't see it properly installed in the Device Manager. Please see attachment.
 

Attachments

  • Driver.png
    Driver.png
    95.2 KB · Views: 161

I have installed the driver in windows 7 when MCP2221 was connected by USB cable to the computer but I don't see it properly installed in the Device Manager. Please see attachment.

You can try other methods of installing a driver.
Example, power up computer and look for a message telling you a new device needs to be installed. The wizard will ask you to navigate the disk in order to find the driver. If you're lucky you'll eventually see a list with only one item, and that item will be the correct driver.
 

I have installed driver for MCP2221, connect power and ground to MCP2221 and PIC16F88, and also connect D+ and D- to USB cable to computer, and UART
Rx and Tx between MCP2221 and PIC16F88 but in Tera Term I do not see any output. The UART is implemented correctly and tested with Tera Term using another chip MAX232 with serial port on computer side.
 

Attachments

  • Driver2.png
    Driver2.png
    76.2 KB · Views: 111
  • Driver3.png
    Driver3.png
    45.3 KB · Views: 115

I have installed driver for MCP2221, connect power and ground to MCP2221 and PIC16F88, and also connect D+ and D- to USB cable to computer, and UART
Rx and Tx between MCP2221 and PIC16F88 but in Tera Term I do not see any output. The UART is implemented correctly and tested with Tera Term using another chip MAX232 with serial port on computer side.

I also check the the default setting of CHIPSetting1 which gives 12 MHz clock with 50 % duty cycle. Following are the connections which I made.

Connect VDD (14) of PIC16F88 to 5V and VSS (5) of PIC16F88 to GND
Connect VDD (1) of MCP2221 to 5V and VSS (14) of MCP2221 to GND
Connect UART URX (5) of MCP2221 to UART UTX (11) of PIC16F88
Connect UART UTX (6) of MCP2221 to UART URX (8) of PIC16F88
Connect D- (12) and D+ (13) of MCP2221 to B type USB connector

I guess the voltage level of UART Rx and Tx between MCP2221 and PIC16F88 is TTL, therefore I connect them directly but there is no output on Tera Term or PuTTY. Any idea how to to check and troubleshoot ? Thanks
 

You can check the MCP2221/USB side by connecting a TX-RX loopback. A terminal program should echo typed characters then (or double echo it if local echo is enabled).

You should check RX and TX lines for useful serial frames with correct level and baud rate.
 

You can check the MCP2221/USB side by connecting a TX-RX loopback. A terminal program should echo typed characters then (or double echo it if local echo is enabled).

You should check RX and TX lines for useful serial frames with correct level and baud rate.

Hi, yes local loop back works when I connect pin (5) and pin (6) of MCP2221 together which are UART RX and TX respectively. I use the setting in Tera Term, 9600 Baud, parity none, stop bit one. If I enable local echo I can see double characters on the screen in Tera Term but I am not sure why it does not work with PIC16F88. I have tested UART interface in PIC16F88 with MAX232 separately in Tera Term with same UART setting. it works with PIC16F88. The chip MAX232 convert TTL to UART. Any idea how to check MPC2221 - PIC16F88 UART interface ?
 

These settings have to match in both transmit and receive.

You also may see a setting for data bits (7 or 8) which you must select.

I have performed another loop back test. I have connected USB D+ and USB D- of MCP2221 to USB cable to computer, which appear as virtual COM port. The URx and UTx of MCP2221 which is TTL signal, I have connected them to MAX232 to convert voltage level from TTL to UART voltage. The UART Rx and Tx from MAX232, I have connected to COM port using DB9 connector. I configure Tera Term and PuTTY for same Baud rate setting, and also enable echo on both. One terminal connected to MCP2221 while other terminal connected to MAX232 in same computer. I have tested data sending in both ways, it works perfectly well, please see attachment. If I type characters on one terminal, I can see the characters on the other terminal with echo on the sending terminal.

I am not sure why MCP2221 does not work with PIC16F88 which is programmed and tested separably with MAX232 using serial COM DB9 connector.
 

Attachments

  • terminals.png
    terminals.png
    153.8 KB · Views: 106

Now MCP2221 USB protocol converter works with PIC16F88. The issue was that the ground of USB connector was not connected to common ground MCP2221 and PIC16F88.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top