Fork me on GitHub

Project Notes

#335 MCP2200/Chaser

Using the MCP2200 GPIO from MacOSX. With great power comes great responsibility to blink LEDs.

Build

Here’s quick demo to show it in action:

Build

Notes

The MCP2200 has 8 GPIO pins that can be used for digital input and output. Four of the pins have alternative functions which may render them unavailable.

But GPIO on a USB to UART chip?? Perhaps a few reasons:

  • for control signals to the attached device (like toggle a reset line)
  • for building USB gizmos

I think I’ll do the later;-)

Using the GPIO pins

The I/O pins actually have decent current handling capabilities, from the datasheet:

  • Maximum output current sunk or sourced by any I/O pin: 25 mA
  • Maximum current sunk or soruced by all ports: 90 mA

Using the GPIO pins for digital output involves two HID commands.

  • CONFIGURE: set pin mode in IO_bmap, and
  • SET_CLEAR_OUTPUTS to set or clear pin states

Using the GPIO pins for digital input involves two HID commands.

  • CONFIGURE: set pin mode in IO_bmap, and
  • READ_ALL to get the IO_Port_Val_bmap values

A Chaser Demo

To test the I/O capabilities, I decided on a simple chaser that employs all 8 GPIO pins:

  • GP0 is an active-low input tied to a pushbutton with pull-up resistor and a little RC de-bouncing
  • GP1-7 are outputs that control a series of LEDs (configured as active-low, although it could just as well be the other way around)

chaser.c is a simple program using the hidapi to:

  • run a sequence over the LEDs
  • reverse direction when the button is pressed

Since there is no interrupt capability for input pins (that I’ve discovered), the script polls the input every cycle.

Running the Chaser

I’m running this on MacOSX, but it should work on any *nix-y O/S. Not sure about Windows.

The usual make & run. Here’s how it appears in the console:

$ make && ./chaser
make: `chaser' is up to date.
Configuring the GPIO pins..
Running the LED chaser thru MCP2200 GPIO (GP1-7); ctrl-c to end ..
.. button pressed on GP0, reversing ..
.. button pressed on GP0, reversing ..
.. button pressed on GP0, reversing ..
^CDeconfiguring the GPIO pins..done. Goodbye!

Construction

Schematic

I tried this first on a breadboard

Breadboard

Chaser_bb_build

Here’s a quick demo on the breadboard:

Build

For no particular reason, I decided to put the circuit on a bit of protoboard, with pin headers to accommodate the MCP2200 DevKit. Here’s a sketch of the layout I used:

Chaser_protoboard_layout

And here’s the final module

Chaser_protoboard_build Build

Credits and References

About LEAP#335 UARTUSBLED
Project Source on GitHub Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is my personal collection of electronics projects, usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting (IMHO!).

The projects are usually inspired by things found wild on the net, or ideas from the sources such as:

Feel free to borrow liberally, and if you spot any issues do let me know. See the individual projects for credits where due. There are even now a few projects contributed by others - send your own over in a pull request if you would also like to add to this collection.