Mixed voltage interfacing with the Bus Pirate

oc.470.iii

Most of the parts we use operate at 3.3volts, but we still run into a lot of old 5volt stuff, and an occasional 2.5volt or 1.8volt part. This post explains how to use the Bus Pirate’s open collector pin mode to interface with parts at different voltages.

We’ve got more details and some example scenarios below the break. Yup, this is another Bus Pirate post. It’ll all be over soon though, because there’s a few days left to get your own Bus Pirate for $30, fully assembled and shipped worldwide.

Overview

The Bus Pirate has a normal pin mode and an open collector pin mode (also called high-impedance or HiZ). Normal pin mode can tolerate up to 5.5volts on input pins, but the output pins are fixed at 3.3volts. The open collector pin mode uses a pull-up resistor to set the bus voltage to something other than 3.3volts. Normal or open collector pin mode is offered as a configuration option after you select a protocol library in the Bus Pirate terminal (menu m). Some bus types always require open collector outputs with pull-up resistors, like 1-wire and I2C.

The image above shows a representation of normal and open collector pin functions.

Normal pin mode

Normal pins switch between the positive supply voltage (high state, usually 1) and ground (low state, usually 0), in the Bus Pirate that’s 3.3volts and 0volts respectively. A normal pin is depicted on the left, switch 1 (S1) toggles the output between supply (V+) and ground (GND).

Open collector mode

In open collector mode, pins switch between a ‘disconnected’ state (high impedance) and ground (low state, usually 0). The voltage that signals a high state is supplied by a pull-up resistor (R1). Without a pull-up resistor the attached devices will never register a high state. We can feed any voltage into the pull-up resistors that the Bus Pirate will tolerate, so we can use this mode to interface devices above and below 3.3volts.

An open collector output is depicted on the right. Switch 2 (S2) can only connect to ground. A resistor (R1) connected to the supply voltage (V+) holds the bus high. Most microcontroller pins are tri-state and become high impedance when configured as an input.

This technique isn’t without disadvantages. The maximum possible bus speed is much lower, and the pull-up resistors use a bit of extra current. Make sure every device you connect can tolerate the voltage you plan to use, most 3.3volt devices don’t have 5volt tolerant pins.

Usage examples

Scenario 1 – Bus Pirate interfacing 3.3volt UART/SPI/JTAG/MIDI bus
The Bus Pirate operates at 3.3volts, use normal pin outputs with no pull-up resistors.

Scenario 2 – Bus Pirate interfacing 5volt UART/SPI/JTAG/MIDI bus
The Bus pirate inputs are 5volt tolerant, but the output is only at 3.3volts. Use open collector outputs (HiZ) with pull-up resistors connected to the 5volt power supply.

Scenario 3 – Bus Pirate interfacing 2volt UART/SPI/JTAG/MIDI bus
The Bus pirate output is 3.3volts, which might damage a 2volt part. Use open collector outputs (HiZ) with pull-up resistors connected to the 2volt power supply.

Scenario 4 – Bus Pirate interfacing a 1-wire or I2C bus between 1.8volts and 5volts
1-wire and I2C are bi-directional, open collector buses. They always require a pull-up resistor to create the high bus state. Use pull-up resistors connected to the 1.8volt to 5volt power supply.

Comments

  1. eric says:

    is the switch symbolizing the changing states in the PIC and everything right of the switch is outside the PIC? if not, i don’t think i understand.

    i hope the bus pirate is still so cool when i get mine in 7 weeks:(

  2. DarkFader says:

    eric, those switches should be in the chip alright. someone was just lazy drawing them.

  3. tikka says:

    I think bus pirate posts are a good idea, since I am going to be a proud owner of one. I think these are informative and useful.

  4. Ian Lesnet says:

    I updated the graphic, is it a little clearer? The switches are the internal workings of the pin.

  5. eric says:

    thanks ian, it may have been clear enough before because i understood correctly but I wasn’t certain. first I was wondering why there would be a switch connected to an output.

    but if it still confuses anyone, these comments should clear things up.

  6. snide says:

    Agreed, this is a good tutorial. Suggest “bus pirate” be added to the list of hacks in the RHS of the page, linking to all bus pirate descriptions and tutorials!

  7. Lloyd Atkinson says:

    Found this by accident in 2013. “Old” 5v parts… hahahahahaha. What a silly thing to say.

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 92,416 other followers