Bus Pirate UART guide

See the latest version on the documentation wiki.

Bus: UART, MIDI (universal asynchronous receiver transmitter).
Connections: two pins (RX/TX) and ground.
Output types: 3.3volt normal output, or open collector (pull-up resistors required).
Pull-up resistors: required for open collector output mode (2K – 10K).
Maximum Voltage: 5.5volts (5volt safe).

UART is also known as the common PC serial port. The PC serial port operates at full RS232 voltage levels (-13volts to +13volts) though, which are not compatible with the Bus Pirate.

Syntax Description
A/a/@ Toggle auxiliary pin. Capital “A” sets AUX high, small “a” sets to ground. @ sets aux to input (high impedance mode) and reads the pin value.
D/d Measure voltage on the ADC pin (v1+ hardware only).
W/w Capital ‘W’ enables the on-board power supplies. Small ‘w’ disables them. (v1+ hardware only).
[ Open UART, discard received bytes.
{ Open UART, display data as it arrives asynchronously.
] or } Close UART.
R or r Check UART for byte, or fail if empty. Displays framing (-f) and parity (-p) errors, more. (r:1…255 for bulk reads)
0b Write this binary value. Format is 0b00000000 for a byte, but partial bytes are also fine: 0b1001.
0h/0x Write this HEX value. Format is 0h01 or 0×01. Partial bytes are fine: 0xA. A-F can be lower-case or capital letters.
0-255 Write this decimal value. Any number not preceded by 0x, 0h, or 0b is interpreted as a decimal value.
, Value delimiter. Use a coma or space to separate numbers. Any combination is fine, no delimiter is required between non-number values: {0xa6,0, 0 16 5 0b111 0haF}.
& Delay 1uS. (&:1…255 for multiple delays)
(#) Run macro, (0) for macro list
Macro Description
0 Macro menu
1 Transparent UART bridge. Reset to exit.
2 Live raw UART monitor. Any key exits. More
3 Transparent UART bridge with flow control.

Configuration options

Speed (bps) - 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 31250 (v2.7+).

Data bits and parity - 8/none, 8/even, 8/odd, 9/none.

Stop bits - 1, 2.

Receive polarity - idle 1, idle 0.

Output type - open drain/open collector (high=Hi-Z, low=ground) , normal (high=3.3volts, low=ground). Use open drain/open collector output types with pull-up resistors for multi-voltage interfacing.

Error display

UART mode requires special handling compared to the other Bus Pirate modes because data can arrive at any time. UART mode displays framing and parity errors, and automatically clears buffer overruns.

Parity and framing errors

READ: -p -f 0×40 <<<-p -f flag set

The Bus Pirate reports framing errors (-f) and parity errors (-p) when reading a byte from the UART. It’s unlikely you’ll see these errors unless the UART speed is mismatched with the sender.

Buffer overrun errors

The Bus Pirate hardware has a four-byte UART buffer that holds data until you read it with an ‘r’ command, or until it can be printed to the terminal if live display is enabled with ‘[‘. After it fills, new data will be lost. This is called a buffer overrun.

READ: 0x40 *Bytes dropped*<<<bytes dropped error

The Bus Pirate detects buffer errors, clears them, and alerts you of dropped bytes. The overrun bit is cleared any time you use the r, {, or [ commands. If you close the live UART display (]) and more than 5 bytes come in, the next read command (r) will clear the error and print the *bytes dropped* warning.

Prevent buffer problems by reducing the amount of data the Bus Pirate transfers over USB for each byte of UART data. Raw display mode reduces the four byte hex value 0×00 to a single raw byte value. A better way is to use macro (1) or (2) to view unformatted UART output, this is a 1:1 transfer of bytes that should work at the highest possible speeds.

Transparent UART bridge

UART>(1)<<<macro 1, transparent UART bridge
UART bridge. Space continues, anything else exits.
Reset to exit.

The transparent UART mode macro (1) creates a simple serial->USB bridge. The only way to exit this mode is to reset the Bus Pirate hardware.

Buffer overrun errors that occur during bridge mode are automatically cleared so that data continues as normal (firmware v3.0+). The MODE LED will turn off to alert you of the buffer overrun error.

Macro (3) is a second UART bridge mode that includes the CTS and RTS flow control signals. CTS is on the CS pin (PIC input from external circuit is passed to FTDI USB->serial  chip). RTS is on the CLOCK pin (PIC output mirrors output from FTDI chip).

Note that the Bus Pirate serial port UART facing the computer (the one that connects to the USB->serial converter chip and sends text to your computer) is NOT adjusted to the same speed as the UART bridge. The USB-side serial port UART will continue to operate at the default setting (115200bps) unless adjusted with the ‘b’ menu.

If you use the UART bridge with a computer program that opens the virtual serial port at a different baud rate, say 9600bps, the exchange will  be garbled because the Bus Pirate expects 115200bps input from the computer. Adjust the computer-side serial speed first with the ‘b’ menu, then start the serial bridge at the desired speed.

Live UART monitor

UART>(2)<<<macro 2, UART monitor
Raw UART input. Space to exit.
UART>

The UART monitor macro (2) shows a live display of UART input as raw byte values without any type of formatting. Press any key to exit the live monitor. This mode works best with a terminal that can display raw byte values in a variety of formats.

This macro is like the transparent UART macro (1) but without transmission abilities, and it can be exited with a key press. It’s useful for monitoring high-speed UART input that causes buffer overrun errors in other modes.

MIDI

MIDI is a command set used by electronic (music) instruments. It travels over a standard serial UART configured for 31250bps/8/n/1. Since firmware v2.7 MIDI is a speed option in the UART library.

MIDI is a ring network, each node has an input and output socket. Each node passes messages to the next in the ring. The input and outputs are opto-isolated. The signaling is at 5volts, 5ma (current-based signaling). An adapter is required: example 1, example 2.

Connections

Connect the Bus Pirate transmit pin (TX/MOSI) to the UART device receive pin (RX). Connect the Bus Pirate receive pin (RX/MISO) to the UART device transmit pin (TX).

For macros and modes with flow control: CTS is on the CS pin (PIC input from external circuit is passed to FTDI USB->serial  chip). RTS is on the CLOCK pin (PIC output mirrors output from FTDI chip).

Diagram by Uwe Bannow, released under the GNU free documentation license.

Comments

  1. Fernando says:

    Bad link, the “more” link at UART raw monitor macro links to ‘http://http//dangerousprototypes.com/2009/10/19/uart-mode-updates/’, It should be ‘http://dangerousprototypes.com/2009/10/19/uart-mode-updates/’
    Thanks

  2. Charudatt says:

    How about interfacing a RS485 chip to the Bus Pirate to monitor RS485 activity over USB/Serial Port. Can this be done ? also How could you switch from Rx Tx on the RS485 Hardware.

    Thanks.

    • Ian says:

      Sure, as I understand RS485 is async serial over a special transceiver. You’d just need to connect the transceiver to the bus and the Bus Pirate to the transceiver. I’m sorry, I don’t understand the second part of your question.

  3. charudatt says:

    RS485 is a simplex protocol which requires switching of logic level to move from Rx to Transmit mode. In UART, you have flow control signals to acheive this. Can you do this with BP3 an extra pin to switch , of the logic level.

    Thanks for the reply.

    • Ian says:

      The auxiliary pin is free in the UART mode, you could use it with the a/A commands to control directionality. We could also standardize it and add it as an option that automatically switches the CS line up when transmitting. If you’d like to discuss this more, please join us in the forum for Bus Pirate development, the v5.0 todo thread would be a good place.

  4. charudatt says:

    thanks Ian,

    Actually, just received my BP today and was overjoyed wth some of the possibilities that can be done with it.

    My immediate requirement was a MODBUS Scanner, in which i wanted to scan data on the MODBUS network.

    Shure, I will join the forum , and contribute my wishlist.

  5. endre says:

    RS485 sniffing definiteliy would be a great feature!

  6. tissit says:

    A lot of programmers (MSP430, Rabbit, DS89xxx…) use DTR to control reset and access to ROM monitor or bootstrap mode. This would be handy to have. I guess you can use the aux line to do that if writing an application?

  7. tissit says:

    Right, to elaborate, it would be nice to turn the BP into a transparent bridge that asserts some TTL/3v3 signal when the application accessing the USB serial port assers DTR.

  8. Isaac says:

    I have made the transparent bridge, but now I have no idea how to reset the BP to its original state.
    I am quie a noob on the BP so any help would be appreciated.

  9. Ian says:

    Thanks steve. Yes you must unplug and plug the cable to get out of bridge mode.

  10. Isaac says:

    Thanks guys!

    I have doneso but it did not work. After the unplug/replug I got no HiZ/whatever prompt.
    I have tried all possible keystrokes (#,~,&).
    Finally I have rewritten the BP firmware in order to get it working again.

    Isaac

  11. cyrus007 says:

    How can I use 7N1 mode with BP ? Any possibility other than 8N1, 8E1, 8O1 & 9N1 ?

  12. darkomen says:

    I’m trying to connect the bus pirate to a raspberry pi terminal Serial UART, to get a terminal console, but I can’t connect this correctly. What mode i have to use in Buspirate?

  13. ian says:

    you would use the UART mode. I’m nit sure but I’d guess 115200baud 8n1 settings. Make sure to connect rx, TX, and.ground.

  14. darkomen says:

    I did this, I config the BP as UART mode, and execute the macro (3), next, i close the terminal, I execute screen again to connect to raspberry, but nothing appears in the terminal.

    • Mark28 says:

      m >> 3 >> 9 >> 1 >> 1 >> 1 >> 1 >> 1 >> P >> (3)

      mode: UART
      baud rate : 115200
      Data bits : 8, none
      Stop bits : 1
      Recieve Polarity: 1
      Select output type : 1
      Pull up resistors: ON
      Macro menu: Bridge with flow control (3)

  15. paco espinola says:

    I am using the buspirate like bridge transparent. I try to comunicate using lpc21isp with linux with no success.
    I configure the buspirate using minicom. So if I send a string manually using minicom by example “?” that works fine.
    but outside minicom if I send the same string “?” manually echo “?” > /dev/buspirate the bus pirate do not send any string to tx. only works if I send echo “\”?\”” > /dev/buspirate
    is there some way to make buspirate alway send the data to tx?

    Thank you in advance

  16. Manuel Rabade says:

    Hello,

    I am configuring the UART mode in 9 bits but the ouput only shows 8 bits ¿How or where the 9 bit is displayed?

    Thank you!

  17. Manuel says:

    Hello,

    I am trying to read a 9 bits serial bus (UART mode 9 bits) but the serial console only displays 8 bits. The data appears to be correct but the MSB is missing (only 8 bits are displayed) Where or how can i see the 9 bit?

    Thank you!

  18. Ulambayar says:

    How to sniff PIC18 TTL using bus prirate?

  19. Ulambayar says:

    How to sniff PIC18 TTL using bus pirate?

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.