Hardware Click for a full size PCB placement image (PNG). Raw 3 wire mode uses the same pin configuration as SPI. The circuit and PCB are designed using the freeware version of Cadsoft Eagle. We used a PIC24FJ64GA002 microcontroller in the Bus Pirate; this is the same chip we used in our mini-server project.
It’s fast enough to do everything we want (16MIPS), and the peripheral pin select feature allows the hardware SPI, UART, and I2C modules to share output pins. Using it Here are two examples that show the Bus Pirate in action.
5volts is supplied by a common 7805 regulator (VR2) and two decoupling capacitors (C9,10). First, a write command with no data sets the address pointer.
An LM317 adjustable regulator (VR1) is set to 3.3volts using two resistors (R2,3), and requires two decoupling capacitors (C6,7). Firmware The firmware is written in C using the free demonstration version of the PIC C30 compiler. bus Pirate.c – Abstraction routines that convert syntax to actions on the proper bus. m_i2c_1.c – Software I2C routines by [Michael Pearce]. Format is 0b00000000 for a byte, but partial bytes are also fine: 0b1001. Second, a read command outputs data starting at the location set in step 1.
Several standard serial protocols are supported at 3.3-5volts, including I2C, SPI, and asynchronous serial.
Pins 21 and 22 (RB10/11) can pull-up SDA/SCL through resistors R4 and R5. A write begins by addressing the device (1 byte) and looking for an acknowledgment bit (ACK).
This chip converts 3.3volt serial output to /-10volt RS232 signals compatible with a PC serial port. If the EEPROM responds, we can send the data location to write (2 bytes) and data payload (n bytes).
Learn all about working with this PIC in our introduction to the PIC 24F series. We couldn’t get the PIC hardware I2C to work, so we used this helpful library. RS232: check UART for byte and return, or fail if empty. The first command is a write command, we use the hexadecimal equivalent of the write address (0b10100110 = 0xa6) to save a bit of typing.
The software doesn’t take into account the I2C speed setting, and seems to work at about 5KHz. The address pointer is set to the location where we wrote our data (0 0). The read address is the device address, with the last bit set to 1 ( 0b10100111 or 0xa7).