Microchip has a new USB->serial converter chip called the MCP2200. We suspected they made this chip from a 20-pin PIC. The MCP2200 pinout is like other PIC uCs, and it has similar reset pin and internal voltage regulator circuits.
We hooked up our trusty PICKIT3 and read the device ID. The MCP2200 was recognized as a PIC 18F14K50! Save a few pennies if you need a 18F14K50 and buy the MCP2200 instead, the MCP2200 is currently cheaper than the blank PIC!
The firmware is probably based on the Microchip USB stack, but we’ll never know because the code is protected. Forget that! We decided to give it an open source firmware instead. Follow our hack below.
According to the datasheet, the USB D+ and D- pins are shared with the programming pins (PGC and PGD).
The /MCLR reset signal needs to be soldered to R6 (chipside). It’s better to add a series diode (D5) to protect the chip.
Be aware the PGC/PGD pins aren’t 5V tolerant (3.6volt max) and the /MCLR can’t stand more then 8V5!! It seems that the PICKIT3 manages this ok when supply is set to 3V3, or the PIC is very robust.
If unsure use this circuit to protect your PIC. It adds some voltage protection for the programming and reset pins using zener diodes.
Dump the code
Hackers as we are, we decided to read the chip and see what makes it tick. Unfortunately the chip returns all 0’s and the configwords told us why, it was code protected. That was a huge bummer: since we can’t read the code, we cannot return it to the original firmware after we start messing with it.
Liberate the MCP2200 with open source!
Let’s write our own firmware for the chip. We could use the USB stack Microchip provides, and write “open” firmware that mimics the current behavior of the MCP2200. Unfortunately Microchip has a fuzzy license agreement which doesn’t allow anybody to release sourcecode with their USB stack included. Recently Honken released an open source USB stack we can use instead.
Porting the stack was harder then we anticipated, as the PIC18F14K50 (also the PIC18F13K50) appears to be a bit crippled compared to the other PIC18s with USB support. It has very little (USB)RAM (256 bytes), and just 8 endpoints instead of the normal 16.
We compiled a test firmware with MPLAB and C18, and loaded it into the MCP2200. The current code just echoes the bytes back, but it won’t be long before we come up with a complete open source replacement firmware. We had a couple of issues with MPLAB and our PICKIT3 so we had to flash the chip from the commandline. The code is as usual in our SVN.
One word about compiling the firmware yourself: every USB device needs to have an unique VendorID and ProductID pair for the OS to know which driver to load. The USB.org tracks the VIDs and ensure they are globally unique, however there aren’t any ranges for testing or amateur electronics. Getting a VID is a challenging task for a group like us. Microchip offers a ‘free’ PID under their VID for little projects that use Microchip ICs, but that comes with a restrictive license.
You need to supply your own USB ID in USB_CONFIG.H. We don’t provide a VID/PID pair in the MCP2200 replacement firmware source, but the factory default is easy enough to find in the .inf if you need one for your experiments.
What are you gonna do with your MCP2200?
- MCP2200 circuit and breakout board overview
- Honken’s open source USB stack for MCP2200 (and more PICs too!)
- MCP2200 homepage, datasheet, etc
- PIC 18F14K50 homepage, datasheet, etc
- Buy the MCP2200 breakout for $15
- Buy the SOIC Protoboard for $10
PIC 18F14K50 specs
|Program Memory Type||Flash|
|Program Memory (KB)||16|
|CPU Speed (MIPS)||12|
|Data EEPROM (bytes)||256|
|Digital Communication Peripherals||1-A/E/USART, 1-MSSP(SPI/I2C)|
|Capture/Compare/PWM Peripherals||1 ECCP|
|Timers||1 x 8-bit, 3 x 16-bit|
|ADC||9 ch, 10-bit|
|USB (ch, speed, compliance)||1, Full Speed, USB 2.0|
|Temperature Range (C)||-40 to 125|
|Operating Voltage Range (V)||1.8 to 5.5|
|Cap Touch Channels||9|