FT-2232 bridges Python and I2C/SPI

You might already have the hardware on hand to easily interface I2C and SPI devices with Python scripts on your computer. The board seen above is an FT-2232 breakout board. These chips are often used to facilitate JTAG programming via USB, but they have other features that might be useful to you as well. The chip has a Multi-Protocol Synchronous Serial Engine (MPSSE) which can speak the I2C and SPI protocols, you just need to know how to active them in your code.

[Craig] makes this easy with his MPSSE Python wrapper. Simply install his module, and you’ll be able to import all the commands you need. He demonstrates reading the data out of a 1 MB SPI flash memory chip. This could be used for a lot more, including debugging peripherals à la the Bus Pirate, or reprogramming chips to add to your projects (we’re thinking font arrays and sprites for displays, or look-up tables).

If you’re not aware, these FTDI chips were the go-to for USB support for a long time. We’ve got a guide for bit-banging using this hardware. Lately more chips have become available with USB hardware built-in. They’re quite useful and cost-effective, especially with the availability of open-source stacks like the LUFA project.

Comments

  1. jc says:

    Next up: a 7805 stabilizes voltage.

  2. sokrasins says:

    It’s as if you psychically KNEW I spent all last night struggling with the FTDI-provided MPSSE solution. This article is much clearer, and much appreciated!

  3. drew says:

    à la the Bus Pirate??? i guess that’s why Ian made the busblaster

  4. Craig says:

    The FT-2232 should not be confused with the FT-232R. The FT-2232 actually has native support for JTAG, SPI and I2C protocols. FTA:

    “The FT-2232′s Multi-Protocol Synchronous Serial Engine (MPSSE) also supports the SPI and I2C protocols, clock rates of up to 30MHz, and a full-speed USB interface.”

    So this will be much faster than trying to bit-bang these protocols through a FT-232R, and probably faster than many uC’s too.

    @drew:

    Yes, the busblaster is based on the FT-2232 chip as well, but AFAIK it is targeted primarily at JTAG. With this library you can extend its functionality to support SPI and I2C as well (although you may need to re-program the CPLD too).

  5. doom says:

    A quick heads up: this ic does not support SPI mode 1 and 3, which is quite annoying.

    • Craig says:

      FTDI’s libmpsse_spi library does not support SPI modes 1 and 3, but the open source libmpsse library does.

      I have tested mode 3 on an SPI flash chip and it works fine; I don’t have any devices that support mode 1 at the moment, but it looks good on the ‘scope.

  6. Jimbo says:

    AVRDUDE 5.11 now also supports the SPI MPSSE engine in these FTDI **232H/C/D chips. This is handy for you Arduino types if you need to reinstall the Arduino bootloader. You can grab the Windows version at http://helix.air.net.au

  7. hboy007 says:

    FTDI says the LibMPSSE_SPI is supposed to be a good starting point for your development with FT2232H and the like.

    Thanks for the article pointing towards the open libmpsse implementation – will have to give it a go when libmpsse_spi fails to deliver SPI_ReadWrite.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 94,477 other followers