Mixed voltage interfacing with the Bus Pirate

posted Jul 1st 2009 11:23am by Ian
filed under: misc hacks, tool hacks

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.

Recent Posts



Reader Comments

Leave a Reply

Hack a Day serves up fresh hacks each day, every day from around the web and a special How-To hack each week.

Send us your hacks











Hacks

Resources

RSS newsfeeds

Powered by WordPress

Most commented on (30 days)

Recent comments