Thursday, December 24, 2015

Bus Pirate v3 Direct IO Pins

My wife got me a Bus Pirate (among other things) for Christmas/Saturnalia/Yule/Whatever.  For the unfamiliar, a Bus Pirate is a small USB device used to communicate with various chips over standard buses such as I2C and SPI.  It also has some other neat features like pulse with modulation and frequency measurement, and can even be pressed into service as a JTAG programmer and (very low speed) logic analyzer and oscilloscope.  Essentially, it is the Swiss Army Knife of electronic tools.

I don't have any I2C or SPI stuff laying around to mess with right now, but I am planning to start working on something in the near future that will require me to bit bang a very simple protocol.  Because of this, I'm messing with writing data from the pirate in direct i/o (DIO) mode.

When writing data in DIO mode, you simply give the pirate an 8 bit value and it sets the pins appropriately.  You only have five pins (CS, MISO, CLK, MOSI, and AUX) to twiddle your bits with.  These are represented by the five least significant bits. The table below represents the bits


BitPin
1CS
2MISO
3CLK
4MOSI
5AUX

If you want to turn more pins on, simply do a bitwise OR of the values you wish to change. For example, entering a 5 would turn on CLK and CS. (0b100 ^ 0b001 = 0b101 = 5). More to come later.

No comments:

Post a Comment