Home > News & Updates > Electronics News Updates > MCP2221 HID Library

MCP2221 HID Library

Summary of MCP2221 HID Library


This article introduces an open-source, multi-platform library for the Microchip MCP2221 USB-to-UART/I2C converter, utilizing HIDAPI to replace proprietary DLLs. It details the chip's features, including GPIO pins, ADCs, DAC, and low power consumption modes. The text highlights performance limitations, noting a significant throughput gap at high baud rates compared to alternatives like the CH340. It also provides specific guidance on handling unconnected pins and configuring the device for remote wake-up functionality.

Parts used in the MCP2221 HID Library Project:

  • MCP2221 USB to UART and I2C/SMBus serial converter
  • HIDAPI library
  • Microchip proprietary DLLs (for comparison)
  • CH340 UART converter IC (for performance comparison)
  • PIC16F1455 (internal microcontroller of MCP2221)
  • Capacitors (1 for 3.3V or 2 for 5V power)

This is a library for interfacing with the HID features of the MCP2221 USB to UART and I2C/SMBus serial converter from Microchip. The converter includes 4 GPIO pins, 3x 10-bit ADCs, 1x 5-bit DAC and more.
Microchip does provide a library for interfacing with the chip, however it is supplied as proprietary DLLs. This project aims to be an open-source and multi-platform alternative.
This library also makes use of HIDAPI.

Bits of info about the MCP2221

  • Doesn’t use a crystal, only requires 1 small capacitor when powered with 3.3V or 2 capacitors when powered with 5V.
  • Available in a hacker friendly DIP package.
  • Has a remote wake function which when used in conjunction with the interrupt input can be used to wakeup the USB host (usually a PC), just like waking up from a keyboard or mouse press.
  • The raw value of the I2C pins can also be read, allowing them to be used as an additional 2 general purpose input pins.
  • Unfortunately there are no options for enabling any internal pull-up/down resistors.
  • The MCP2221 seems to be a PIC16F1455. [Source]
  • Current consumption @ 3.3V with USB disconnected can be anywhere between 20uA and 70uA, not sure what causes such a difference. Remote wakeup needs to be disabled (default) otherwise current consumption will be about 5mA.
  • Kinda slow compared to other USB/UART converters. Even with the baud rate set to 1,000,000 its overall throughput is only about 250,000 bps. More about this below.

MCP2221 HID Library

Unconnected pins
The usual way to deal with unconnected pins are to enable their internal pull-up/down resistors, but this chip doesn’t support them. Instead it’s probably best to set unconnected pins as output high or low.
The I2C pins are a little different since they can’t be set to outputs, though there’s still few options:

UART Throughput
The main UART function seems to be really slow, maxing out at about 250,000 bps throughput when set to 1,000,000 baud due to a gap of about 30us after each byte transmitted. This isn’t much of a problem at lower bauds, but as the baud rate increases it creates a huge overhead (75% @ 1Mbaud!). Attempting to receive data without a sufficient gap will also corrupt the data. Here are some screen shots comparing the MCP2221 and CH340 UART converter ICs transmitting data at 1,000,000 baud. The MCP2221 has a gap of about 30us between each byte, while the CH340 has a gap of just 1us.

For More Details: MCP2221 HID Library

Quick Solutions to Questions related to MCP2221 HID Library Project:

  • What is the primary goal of this project?
    The project aims to provide an open-source and multi-platform alternative to the proprietary DLLs supplied by Microchip.
  • Does the MCP2221 require a crystal oscillator?
    No, it does not use a crystal and only requires one small capacitor when powered with 3.3V.
  • Can internal pull-up/down resistors be enabled on the MCP2221?
    Unfortunately, there are no options for enabling any internal pull-up/down resistors on this chip.
  • How should unconnected pins be handled if pull-ups are unavailable?
    It is best to set unconnected pins as output high or low, except for I2C pins which cannot be set to outputs.
  • What is the maximum effective throughput of the MCP2221 UART function?
    The overall throughput is only about 250,000 bps even when the baud rate is set to 1,000,000.
  • Why is the MCP2221 considered slow compared to other converters?
    There is a gap of about 30us after each byte transmitted, creating a huge overhead at higher baud rates.
  • How can the USB host be woken up using this device?
    The remote wake function can be used in conjunction with the interrupt input to wake up the USB host.
  • What is the current consumption when remote wakeup is disabled?
    Current consumption @ 3.3V with USB disconnected ranges between 20uA and 70uA when remote wakeup is disabled.
  • What happens if data is received without a sufficient gap?
    Attempting to receive data without a sufficient gap will corrupt the data.
  • Which internal component does the MCP2221 seem to be based on?
    The MCP2221 seems to be a PIC16F1455.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top