<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Hack a Day &#187; serial port</title>
	<atom:link href="http://hackaday.com/tag/serial-port/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackaday.com</link>
	<description>Fresh hacks every day</description>
	<lastBuildDate>Fri, 10 Feb 2012 12:45:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='hackaday.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/5560f98f805877b0e332f191cb9e0af3?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Hack a Day &#187; serial port</title>
		<link>http://hackaday.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://hackaday.com/osd.xml" title="Hack a Day" />
	<atom:link rel='hub' href='http://hackaday.com/?pushpress=hub'/>
		<item>
		<title>Sound card microcontroller/PC communication</title>
		<link>http://hackaday.com/2011/07/10/sound-card-microcontrollerpc-communication/</link>
		<comments>http://hackaday.com/2011/07/10/sound-card-microcontrollerpc-communication/#comments</comments>
		<pubDate>Sun, 10 Jul 2011 21:01:25 +0000</pubDate>
		<dc:creator>Brian Benchoff</dc:creator>
				<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[communication]]></category>
		<category><![CDATA[microcontroller]]></category>
		<category><![CDATA[serial port]]></category>
		<category><![CDATA[usb]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=48536</guid>
		<description><![CDATA[The usual way send data from a microcontroller is either over RS-232 with MAX232 serial ICs, crystals, and a relatively ancient computer, or by bit-banging the USB protocol and worrying about driver issues. Not content with these solutions, [Scott] came up with sound card μC/PC communication that doesn&#8217;t require any extra components. [Scott] bought a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=48536&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-large wp-image-48537" title="soundcard" src="http://hackadaycom.files.wordpress.com/2011/07/soundcard.jpg?w=450&#038;h=219" alt="" width="450" height="219" /></p>
<p>The usual way send data from a microcontroller is either over RS-232 with MAX232 serial ICs, crystals, and a relatively ancient computer, or by bit-banging the USB protocol and worrying about driver issues. Not content with these solutions, [Scott] came up with <a href="http://www.swharden.com/blog/2011-07-09-sound-card-microcontrollerpc-communication/">sound card μC/PC communication</a> that doesn&#8217;t require any extra components.</p>
<p>[Scott] bought a cheap USB sound card dongle on eBay (although a built-in sound card will do) and wired up the tip and ring of the plug to the microcontroller. The data is sent from the microcontroller a lot like Morse code &#8211; a short gap between pulses is a zero, a long gap is a one. This is parsed by a Python script using PyAudio. Synchronization, timing, and calibration is automatic because of a 10-bit &#8216;packet header&#8217; <a href="http://www.youtube.com/watch?v=WKp0P43uhzY">explained in this video</a>.</p>
<p><span id="more-48536"></span></p>
<p>After he had a really great way of sending data from a microcontroller to a PC, [Scott] asked himself if it would be possible to have bidirectional communication. Using the same sound card setup, he managed to get bidirectional communication off an ATtiny44a. You can see his demo video of this <a href="http://www.youtube.com/watch?v=fhsYGRdwIaw">here</a>.</p>
<p>The cleverness of hack is overwhelming, and we&#8217;re kind of amazed that this technique isn&#8217;t in the standard repertoire of solder monkeys. After looking at this, we&#8217;re tempted to throw out the half-dozen USB/RS-232 adapters we have lying around. They never worked anyway. Check out [Scott]&#8216;s highly informative video of his build below.</p>
<span style="text-align:center; display: block;"><a href="http://hackaday.com/2011/07/10/sound-card-microcontrollerpc-communication/"><img src="http://img.youtube.com/vi/I0UEooQH2bw/2.jpg" alt="" /></a></span>
<br />Filed under: <a href='http://hackaday.com/category/microcontrollers/'>Microcontrollers</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/48536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/48536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/48536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/48536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/48536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/48536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/48536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/48536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/48536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/48536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/48536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/48536/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/48536/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/48536/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=48536&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2011/07/10/sound-card-microcontrollerpc-communication/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">brianbenchoff</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/07/soundcard.jpg?w=450" medium="image">
			<media:title type="html">soundcard</media:title>
		</media:content>
	</item>
		<item>
		<title>Serial port JTAG programmer</title>
		<link>http://hackaday.com/2011/05/22/serial-port-jtag-programmer/</link>
		<comments>http://hackaday.com/2011/05/22/serial-port-jtag-programmer/#comments</comments>
		<pubDate>Sun, 22 May 2011 23:45:19 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[jtag]]></category>
		<category><![CDATA[programmer]]></category>
		<category><![CDATA[serial port]]></category>
		<category><![CDATA[voltage divider]]></category>
		<category><![CDATA[zener diode]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=43412</guid>
		<description><![CDATA[If you&#8217;re planning to do some hacking with CPLD or FPGA chips you&#8217;ll need a way to program them. JTAG is one of the options and here&#8217;s a cheap method that uses the serial port (translated). This method requires only four signals (TDI, TMS, TCK and TDO) plus ground. But the problem is that an RS232 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=43412&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-43413" title="serial-port-jtag-programmer" src="http://hackadaycom.files.wordpress.com/2011/05/serial-port-jtag-programmer-e1306095415984.jpg" alt="" width="470" height="353" /></p>
<p>If you&#8217;re planning to do some hacking with CPLD or FPGA chips you&#8217;ll need a way to program them. JTAG is one of the options and here&#8217;s <a href="http://marsohod.org/index.php/ourblog/11-blog/163-marsblaster">a cheap method that uses the serial port</a> (<a href="http://translate.google.com/translate?js=n&amp;prev=_t&amp;hl=en&amp;ie=UTF-8&amp;layout=2&amp;eotf=1&amp;sl=auto&amp;tl=en&amp;u=http%3A%2F%2Fmarsohod.org%2Findex.php%2Fourblog%2F11-blog%2F163-marsblaster">translated</a>).</p>
<p>This method requires only four signals (TDI, TMS, TCK and TDO) plus ground. But the problem is that an RS232 serial port operates with 12V logic levels and the JTAG side of the programmer needs to operate with the logic levels native to the device you&#8217;re programming. Commercial programmers use a level convert IC to take care of this for you, but that doesn&#8217;t mesh with the cheap goal of this project. Instead, [Nicholas] uses Zener diodes and voltage dividers to make the conversion. There is also an LED for each data signal to give some feedback if you&#8217;re having trouble.</p>
<p>You can use this along with a programming application that [Nicholas] whipped up using Visual Studio. It works well via the serial port, but he did try programming with a USB-to-Serial dongle. He found that this method slows the process down to an unbearable 5-minutes. Take a look, maybe you can help to get that sloth-like programming up to a manageable speed.</p>
<p>[Thanks Alex]</p>
<br />Filed under: <a href='http://hackaday.com/category/tool-hacks/'>tool hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/43412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/43412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/43412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/43412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/43412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/43412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/43412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/43412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/43412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/43412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/43412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/43412/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/43412/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/43412/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=43412&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2011/05/22/serial-port-jtag-programmer/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2011/05/serial-port-jtag-programmer-e1306095415984.jpg" medium="image">
			<media:title type="html">serial-port-jtag-programmer</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding a serial port through an RJ45 connector</title>
		<link>http://hackaday.com/2010/12/30/adding-a-serial-port-through-an-rj45-connector/</link>
		<comments>http://hackaday.com/2010/12/30/adding-a-serial-port-through-an-rj45-connector/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 17:00:43 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[peripherals hacks]]></category>
		<category><![CDATA[ethernet]]></category>
		<category><![CDATA[rj45]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[rt-n12]]></category>
		<category><![CDATA[serial port]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=32228</guid>
		<description><![CDATA[[Mike Lu] likes to add serial ports to his routers to use for debugging but he didn&#8217;t want to drill holes in his new RT-N12. After a bit of head-scratching he thought about repurposing the four unused wires on one of the RJ45 Ethernet connectors. This would allow him to interface with the necessary signals [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=32228&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-32229" title="serial-port-via-rj45" src="http://hackadaycom.files.wordpress.com/2010/12/serial-port-via-rj45.jpg" alt="" width="470" height="381" /></p>
<p>[Mike Lu] likes to add serial ports to his routers to use for debugging but he didn&#8217;t want to drill holes in his new RT-N12. After a bit of head-scratching he thought about <a href="http://www.dd-wrt.com/phpBB2/viewtopic.php?t=85004">repurposing the four unused wires on one of the RJ45 Ethernet connectors</a>. This would allow him to interface with the necessary signals and still have the option of using that port for a network connection. The first step was to build the circuit to output the correct serial levels and connect it to the unused pins on the jack. Next, to separate serial and Ethernet on the outside of the router he build a short adapter cable.</p>
<p>This is an elegant solution if you&#8217;re looking for zero case modifications. But if you don&#8217;t mind a few inconspicuous holes we love <a href="http://hackaday.com/2010/07/22/adding-a-serial-port-to-a-dockstar/">the serial port used on this Dockstar</a>.</p>
<br />Filed under: <a href='http://hackaday.com/category/peripherals-hacks/'>peripherals hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/32228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/32228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/32228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/32228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/32228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/32228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/32228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/32228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/32228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/32228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/32228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/32228/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/32228/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/32228/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=32228&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2010/12/30/adding-a-serial-port-through-an-rj45-connector/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2010/12/serial-port-via-rj45.jpg" medium="image">
			<media:title type="html">serial-port-via-rj45</media:title>
		</media:content>
	</item>
		<item>
		<title>Adding a serial port to the Zipit</title>
		<link>http://hackaday.com/2010/06/24/adding-a-serial-port-to-the-zipit/</link>
		<comments>http://hackaday.com/2010/06/24/adding-a-serial-port-to-the-zipit/#comments</comments>
		<pubDate>Thu, 24 Jun 2010 20:00:12 +0000</pubDate>
		<dc:creator>Mike Szczys</dc:creator>
				<category><![CDATA[handhelds hacks]]></category>
		<category><![CDATA[linux hacks]]></category>
		<category><![CDATA[3.5mm]]></category>
		<category><![CDATA[adapter]]></category>
		<category><![CDATA[rs232]]></category>
		<category><![CDATA[serial port]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=25358</guid>
		<description><![CDATA[[Geordy] added a serial port to his Zipit. It uses a 3.5mm jack as the connector. He managed to include an RS232 level converter inside the case. Both components were hard to fit into the cramped quarters but he did it and he kept the hacker-friendly device looking nice too. Filed under: handhelds hacks, linux hacks<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=25358&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-25360" title="zipit-serial-port" src="http://hackadaycom.files.wordpress.com/2010/06/zipit-serial-port1.jpg" alt="" width="470" height="348" /></p>
<p>[Geordy] <a href="http://www.notanon.com/gadgets/adding-a-serial-port-to-the-zipit-z2-with-an-internal-serial-level-shifter/2010/06/24/">added a serial port to his Zipit</a>. It uses a 3.5mm jack as the connector. He managed to include an RS232 level converter inside the case. Both components were hard to fit into the cramped quarters but he did it and he kept <a href="http://hackaday.com/2009/09/25/with-zipit-who-needs-a-netbook/">the hacker-friendly device</a> looking nice too.</p>
<br />Filed under: <a href='http://hackaday.com/category/handhelds-hacks/'>handhelds hacks</a>, <a href='http://hackaday.com/category/linux-hacks/'>linux hacks</a>  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/25358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/25358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/25358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/25358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/25358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/25358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/25358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/25358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/25358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/25358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/25358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/25358/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/25358/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/25358/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=25358&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2010/06/24/adding-a-serial-port-to-the-zipit/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Mike Szczys</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2010/06/zipit-serial-port1.jpg" medium="image">
			<media:title type="html">zipit-serial-port</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: Bus Pirate v1, improved universal serial interface</title>
		<link>http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface/</link>
		<comments>http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 02:43:56 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[i2c]]></category>
		<category><![CDATA[interface]]></category>
		<category><![CDATA[interface tools]]></category>
		<category><![CDATA[jtag]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[pc at keyboard]]></category>
		<category><![CDATA[scancode]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[serial port]]></category>
		<category><![CDATA[spi]]></category>
		<category><![CDATA[uart]]></category>
		<category><![CDATA[universal interface]]></category>

		<guid isPermaLink="false">http://hackaday.com/?p=7361</guid>
		<description><![CDATA[We use the Bus Pirate to interface a new chip without writing code or designing a PCB. Based on your feedback, and our experience using the original Bus Pirate to demonstrate various parts, we updated the design with new features and cheaper components. There&#8217;s also a firmware update for both Bus Pirate hardware versions, with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=7361&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-8068" title="front450a" src="http://hackadaycom.files.wordpress.com/2009/01/front450a.jpg" alt="front450a" width="450" height="269" /></p>
<p>We use the Bus Pirate to interface a new chip without writing code or designing a PCB. Based on your feedback, and our experience using <a href="http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/">the original Bus Pirate</a> to demonstrate various <a href="http://hackaday.com/category/parts/">parts</a>, we updated the design with new features and cheaper components.</p>
<p>There&#8217;s also a firmware update for both Bus Pirate hardware versions, with bug fixes, and a PC AT keyboard decoder. Check out the new <a href="http://hackaday.com/the-bus-pirate-universal-serial-interface/">Hack a Day Bus Pirate page</a>, and browse the Bus Pirate source code in our <a href="http://code.google.com/p/the-bus-pirate/source/browse/">Google code SVN repository</a>.</p>
<p>We cover the design updates and interface a digital to analog converter below.</p>
<p><span id="more-7361"></span></p>
<p><strong>Concept overview</strong></p>
<p><strong><img class="alignnone size-full wp-image-8067" title="overview-diagram1" src="http://hackadaycom.files.wordpress.com/2009/01/overview-diagram1.png" alt="overview-diagram1" width="450" height="212" /><br />
</strong></p>
<p>The Bus Pirate started as a collection of code fragments we used to test new chips without endless compile-program-run development cycles. We released it in a how-to and used it to demonstrate a bunch of serial interface ICs in our <a href="http://hackadaycom.wordpress.com/category/parts/">parts posts</a>. This article introduces an updated design with new features and a bunch of improvements.</p>
<ul>
<li>Surface mount design</li>
<li>Pull-up resistors on all bus lines with external voltage source</li>
<li>Software resettable 3.3volt and 5volt power supplies</li>
<li>Voltage monitoring of all power supplies</li>
<li>An external voltage measurement probe</li>
<li>Cheaper parts</li>
</ul>
<p><img class="alignnone size-full wp-image-7996" title="top" src="http://hackadaycom.files.wordpress.com/2009/01/top.jpg" alt="top" width="450" height="254" /></p>
<p><strong>Hardware</strong></p>
<p><strong><img class="alignnone size-full wp-image-8001" title="cct-450" src="http://hackadaycom.files.wordpress.com/2009/01/cct-450.jpg" alt="cct-450" width="450" height="140" /></strong></p>
<p><a href="http://hackadaycom.files.wordpress.com/2009/01/cct1.png">Click for a full size schematic image</a><strong> </strong>(PNG). The circuit and PCB are designed using the freeware version of <a href="http://www.cadsoft.de/">Cadsoft Eagle</a>. All the files for this project are included in the project archive linked at the end of the article.</p>
<p><em>Microcontroller</em></p>
<p>We used a Microchip <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en026374">PIC24FJ64GA002</a> 28pin SOIC microcontroller (IC1) in this project. The power pins have 0.1uF bypass capacitors to ground (C1,2). The 2.5volt internal regulator requires a 10uF tantalum capacitor (C20). The chip is programmed through a five pin header (ICSP). A 2K pull-up resistor (R1) is required for the MCLR function on pin 1. Read more about this chip in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">PIC24F introduction</a>.</p>
<p><em>RS-232 transceiver<br />
</em></p>
<p>An inexpensive <a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1068">MAX3232CSE</a> RS232 transceiver (IC2) interfaces the PIC to a PC serial port. This chip replaces the expensive through-hole <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=MAX3223EEPP%2B-ND">MAX3223EEPP+</a> used in the previous version of the Bus Pirate. The serial interface will work with a USB-&gt;serial adapter.</p>
<p><em>Bus pull-up resistors</em></p>
<p><em><img class="alignnone size-full wp-image-8006" title="cct-pu450" src="http://hackadaycom.files.wordpress.com/2009/01/cct-pu450.png" alt="cct-pu450" width="450" height="137" /><br />
</em></p>
<p>The original Bus Pirate has 3.3volt pull-up resistors on 2 pins, but most of our tests required additional external resistors. The updated design has pull-up resistors (R20-23) on the three main bus signals (data in, data out, clock) and the chip select (CS) pin.</p>
<p>A row of jumpers (SV5) connects each resistor to an external voltage supplied through the Vext terminal (X4). Through-hole resistors are used like jumper-wires to make the PCB easier to etch at home.</p>
<p>We couldn&#8217;t find an elegant way to control an arbitrary voltage pull-up resistor array from a 3.3volt microcontroller. If you have any ideas, please share them in the comments.</p>
<p><em>Power supply</em></p>
<p>VR1 is a 3.3volt supply for the microcontroller and RS232 transceiver. VR2 is a 5volt supply. Both require two 0.1uF bypass capacitors (C3-C6). J1 is a power supply jack for a common <a href="http://en.wikipedia.org/wiki/DC_connector">2.1mm DC barrel plug</a>. 7-10volts DC is probably the ideal power supply range.</p>
<p><img class="alignnone size-full wp-image-8008" title="cct-vr4" src="http://hackadaycom.files.wordpress.com/2009/01/cct-vr4.png" alt="cct-vr4" width="450" height="230" /></p>
<p>The original Bus Pirate had dual power supplies, 3.3volts and 5volts, so most ICs could be interfaced without an additional power supply. A major annoyance was the lack of a power reset for connected chips. If a misconfigured IC needed to be power-cycled, we had to disconnect a wire. We got so tired of this routine that we added a software controlled reset to the updated design.</p>
<p>VR3 (3.3volts) and VR4 (5volts) are TI <a href="http://focus.ti.com/docs/prod/folders/print/tps79650.html">TPS796XX</a> voltage regulators with an enable switch. A high level on pin 1 enables the regulator. A pull-down resistor (R13,R12) ensures that the regulators are off when the PIC isn&#8217;t actively driving the line, such as during power-up initialization. The datasheet specifies a hefty capacitor on the input (C23, C21) and output (C24, C22) pins, we used the same 10uF tantalum we use everywhere. An additional, optional, 0.1uF capacitor (C12,C11) can improve regulation.</p>
<p>The switchable regulators are powered by VR2, a 5volt supply.  We did this because the maximum input for VR3 and VR4 is 6volts, leaving the device with a narrow 5.2-6volt power supply range. VR2 will work well above 10volts, and provides an adequate supply for the other regulators.</p>
<p>VR3 (3.3volts) has plenty of headroom to operate from a 5volt supply. VR4 (5volts) will lose about 0.2volts, but 4.8volts remains well within the acceptable range for most 5volt chips. In practice, and under light loads, we see less than 0.1volts drop-out from VR4.</p>
<p><em>Voltage monitoring</em></p>
<p><em><img class="alignnone size-full wp-image-8003" title="cct-adcin" src="http://hackadaycom.files.wordpress.com/2009/01/cct-adcin.png" alt="cct-adcin" width="373" height="76" /><br />
</em></p>
<p>Voltage monitoring is a new feature we&#8217;re really excited about. Has your project ever mysteriously stopped responding because of an accidental short circuit? The Bus Pirate&#8217;s power supplies are equipped with voltage monitoring that can detect a change in power levels.</p>
<p>Each monitored signal is connected to an <a href="http://en.wikipedia.org/wiki/Analog-to-digital_converter">analog to digital converter</a> (ADC) through a resistor voltage divider. Two 10K resistors (R10,R11 above) divide the input voltage in half, making it possible to measure up to 6.6volts with the 3.3volt PIC microcontroller.</p>
<p>The Bus Pirate has four voltage monitors. The 3.3volt and 5volt power supplies are monitored, as is the external voltage fed to the pull-up resistors. A fourth monitor is connected to pin 9 of the output header to make a voltage probe.</p>
<p><strong>PCB</strong></p>
<p><strong><img class="alignnone size-large wp-image-8134" title="brd450alt" src="http://hackadaycom.files.wordpress.com/2009/01/brd450alt.png?w=450&#038;h=330" alt="brd450alt" width="450" height="330" /><br />
</strong></p>
<p><a href="http://hackadaycom.files.wordpress.com/2009/01/brd.png">Click for a full size placement diagram</a> (PNG). The board is a quasi single-sided design, we etched ours in the lab on a single-sided photo-resist PCB. At the top, near C13, two jumper wires meet at a single via; we soldered one jumper wire to the other on the back of the board.</p>
<p><em>Part list</em></p>
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td>Part</td>
<td>Value</td>
</tr>
<tr>
<td>IC1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=V/yyTCAHA4D/h5r3CRQDtA==">PIC24FJ64GA002</a> (SOIC)</td>
</tr>
<tr>
<td>IC2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=SN75C3232EDvirtualkey59500000virtualkey595-SN75C3232ED">MAX3232CSE</a> (SOIC-N)</td>
</tr>
<tr>
<td>VR1</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=LD1117S33CTRvirtualkey51120000virtualkey511-LD1117S33C">LD1117S33</a> 3.3volt regulator (SOT223)</td>
</tr>
<tr>
<td>VR2</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=LD1117S50TRvirtualkey51120000virtualkey511-LD1117S50">LD1117s50</a> 5volt regulator (SOT223)</td>
</tr>
<tr>
<td>VR3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMsGz1a6aV8DcPXeWoVS0Fnzr3zi8%252bAr99Q%3d">TPS79633</a> 3.3volt regulator (SOT223-6)</td>
</tr>
<tr>
<td>VR4</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=TPS79650DCQRvirtualkey59500000virtualkey595-TPS79650DCQR">TPS79650</a> 5volt regulator (SOT223-6)</td>
</tr>
<tr>
<td>C1-13</td>
<td><a href="https://www.mouser.com/Search/ProductDetail.aspx?R=C0805C104M5RACTUvirtualkey64600000virtualkey80-C0805C104M5R">0.1uF capacitor</a> (0805)</td>
</tr>
<tr>
<td>C20-24</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=293D106X96R3A2TE3virtualkey61320000virtualkey74-293D106X96R3A2TE3">10uF tantalum capacitor</a> (SMC A)</td>
</tr>
<tr>
<td>R1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=jBethxrBxZb5NLDetw123g%3d%3d">2000 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R2,3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=2BMLUTrrT4P7Xm58YbKmPg==">390 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R4-13</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMtlubZbdhIBIADEshVnklemK%252bhrLNEuMe8%3d">10000 ohm resistor</a> (0805)</td>
</tr>
<tr>
<td>R20-23</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=8tsW7z%2fc78pkoLNVKn1xoQ%3d%3d">2.2K</a>-<a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMtMTfExsNintTsTnthYiOMx%2fND7UkWzrMM%3d">10K</a> ohm resistor (through-hole)</td>
</tr>
<tr>
<td>LED1,2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=7JStj%2fjQ2SElGv%2fp7IzKlg%3d%3d">LED</a> (0805)</td>
</tr>
<tr>
<td>J1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=8xMK%2bwDsXhcfMNb/YnnwLQ==">2.1mm power jack</a></td>
</tr>
<tr>
<td>X2,X4</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=wjes1ZhMGKfGv3iS94oZ%252bQ%3d%3d">screw clamp (2 terminals)</a> *untested</td>
</tr>
<tr>
<td>X3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=nAEW9fCjKd%2fyLNwP2ItddQ%3d%3d"></a><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=nAEW9fCjKd%2fyLNwP2ItddQ%3d%3d">db9 female serial port connector</a> *untested</td>
</tr>
<tr>
<td>ICSP</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=9-146278-0virtualkey57100000virtualkey571-9-146278-0">0.1&#8243; pin header, straight</a></td>
</tr>
<tr>
<td>SV4</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=9-146278-0virtualkey57100000virtualkey571-9-146278-0">0.1&#8243; pin header</a> or shrouded header</td>
</tr>
<tr>
<td>SV5</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=9-146278-0virtualkey57100000virtualkey571-9-146278-0">0.1&#8243; pin header, straight</a></td>
</tr>
</tbody>
</table>
<p><strong>Firmware</strong></p>
<p>The firmware is written in C using the free demonstration version of the <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en010065">PIC C30 compiler</a>. Learn all about working with this PIC in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">introduction to the PIC 24F series</a>.</p>
<p>The latest firmware is posted on the <a href="http://hackaday.com/the-bus-pirate-universal-serial-interface/">Hack a Day Bus Pirate page</a>. The latest source is in our <a href="http://code.google.com/p/the-bus-pirate/source/checkout">Google Code SVN repository</a>.</p>
<p><strong>Using it</strong></p>
<p><strong><img class="alignnone size-full wp-image-8004" title="cct-pinout450" src="http://hackadaycom.files.wordpress.com/2009/01/cct-pinout450.png" alt="cct-pinout450" width="450" height="179" /><br />
</strong></p>
<p>The diagram above shows the Bus Pirate pinout.</p>
<p>We made a cable with alligator clips on the end, and added labels to each wire so we don&#8217;t have to refer to this table every time we interface a new chip.</p>
<p>If you know of any cool connectors or cables, please link to them in the comments.</p>
<p><img class="alignnone size-full wp-image-8066" title="ltc2640" src="http://hackadaycom.files.wordpress.com/2009/01/ltc2640.jpg" alt="ltc2640" width="450" height="354" /></p>
<p><em>LTC2640 SPI digital to analog voltage converter</em></p>
<p>The Linear Technology <a href="http://www.linear.com/pc/productDetail.jsp?navId=H0,C1,C1155,C1005,C1156,P85250">LTC2640-LZ8</a> is an 8bit <a href="http://en.wikipedia.org/wiki/Digital-to-analog_converter">digital to analog converter</a> (DAC) programmed over <a href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">SPI</a>. A DAC is essentially a programmable voltage divider. They&#8217;re useful for recreating waveforms, such as audio signals. An 8bit DAC has 255 even intervals between 0 and the reference voltage, the L part we used has an internal 2.5volt reference.</p>
<p>The LTC2640 only comes in a small SOT223-8 package, so we made a breadboard adapter in the profile of a DIP-8 chip.  Our LTC2640 footprint is included in the project archive attached at the end of this article.</p>
<p><img class="alignnone size-large wp-image-8019" title="ltc2640450" src="http://hackadaycom.files.wordpress.com/2009/01/ltc2640450.png?w=450&#038;h=218" alt="ltc2640450" width="450" height="218" /></p>
<p>The schematic above shows our test circuit for the LTC2640. It requires a 2.7-5volt power supply, we used the Bus Pirate&#8217;s 3.3volt supply. C1 is a bypass capacitor between the power pin and ground. Pin 8 is an active-low reset pin, tie it high for normal operation. Pin 7 is the DAC output, connect the Bus Pirate voltage measurement probe (ADC) here.</p>
<table border="0">
<tbody>
<tr>
<td><strong>Bus Pirate</strong></td>
<td><strong>LTC2640 (pin #)</strong></td>
</tr>
<tr>
<td>MOSI</td>
<td>SDI (3)</td>
</tr>
<tr>
<td>CLOCK</td>
<td>SCK (2)</td>
</tr>
<tr>
<td>CS</td>
<td>CS/LD (1)</td>
</tr>
<tr>
<td>ADC</td>
<td>VOUT (7)</td>
</tr>
<tr>
<td>+3.3volts</td>
<td>CLR (8 )</td>
</tr>
<tr>
<td>+3.3volts</td>
<td>VDD (5)</td>
</tr>
<tr>
<td>GND</td>
<td>GND (4)</td>
</tr>
</tbody>
</table>
<p>We connected the Bus Pirate to the LTC2640 as shown in the table. The LTC2640 doesn&#8217;t have a data output pin, this SPI connection remains unused.</p>
<p>The Bus Pirate&#8217;s hardware SPI library and software RAW3WIRE library are compatible with the LTC2640&#8242;s SPI interface. We used the SPI library; if you use the RAW3WIRE library be sure to choose <em>normal pin output</em>.</p>
<blockquote><p>HiZ&gt;m<strong>&lt;&#8211;select mode</strong><br />
1. HiZ<br />
2. 1-WIRE<br />
3. UART<br />
4. I2C<br />
5. SPI<br />
6. JTAG<br />
7. RAW2WIRE<br />
8. RAW3WIRE<br />
9. PC AT KEYBOARD<br />
MODE&gt;5<strong>&lt;&#8211;SPI or RAW3WIRE</strong><br />
900 MODE SET<br />
Set speed:<br />
1. 30KHz<br />
2. 125KHz<br />
3. 250KHz<br />
4. 1MHz<br />
SPEED&gt;1 <strong>&lt;&#8211;test at low speed</strong><br />
&#8230;<br />
102 SPI READY<br />
SPI&gt;</p></blockquote>
<p>Press M for the Bus Pirate mode menu, choose 5 for SPI mode. There are a bunch of configuration options for the SPI module, use the default options for all of them. After SPI mode is ready we need to configure the power supply.</p>
<blockquote><p>SPI&gt;p<strong>&lt;&#8211;power supply setup</strong><br />
W/w toggles 3.3volt supply?<br />
1. NO<br />
2. YES<br />
MODE&gt;2<strong>&lt;&#8211;use 3.3volt supply</strong><br />
W/w toggles 5volt supply?<br />
1. NO<br />
2. YES<br />
MODE&gt;1<strong>&lt;&#8211;don&#8217;t use 5volt supply</strong><br />
9xx SUPPLY CONFIGURED, USE W/w TO TOGGLE<br />
9xx VOLTAGE MONITOR: 5V: 0.0 | 3.3V: 0.0 | VPULLUP: 0.0 |<br />
SPI&gt;</p></blockquote>
<p>p opens the Bus Pirate power supply menu. We use the 3.3volt supply but not the 5volt supply. The voltage monitor verifies that the power supplies are off.</p>
<blockquote><p>SPI&gt;W<strong>&lt;&#8211;capital W (<a href="http://www.w3.org/TR/CSS2/text.html#caps-prop">silly CSS</a>) enables power supply</strong><br />
9xx 3.3VOLT SUPPLY ON<br />
SPI&gt;v<strong>&lt;&#8211;voltage monitor</strong><br />
9xx VOLTAGE MONITOR: 5V: 0.0 | 3.3V: 3.3 | VPULLUP: 0.0 |<br />
SPI&gt;</p></blockquote>
<p>Capital &#8216;W&#8217; enables any power supplies selected in the previous menu, a small &#8216;w&#8217; disables them. V displays the supply voltage monitor, which now shows 3.3volts output from the 3.3volt supply.</p>
<p>Now that configuration is finished, we can send commands to the LTC2640 over the SPI bus. The LTC2640 has a 24bit (3byte) interface protocol. The first byte is a command, followed by two data bytes. The LTC2640 is available in 8,10, and 12bit versions; the 8bit version uses the first byte to set the DAC value, and ignores the second byte.</p>
<blockquote><p>SPI&gt;[0b00110000 255 0]<strong>&lt;&#8211;set DAC to full</strong><br />
110 SPI CS ENABLED<br />
120 SPI WRITE: 0&#215;30<strong>&lt;&#8211;write DAC command</strong><br />
120 SPI WRITE: 0xFF<strong>&lt;&#8211;DAC value</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;don&#8217;t care</strong><br />
140 CS DISABLED<br />
SPI&gt;</p></blockquote>
<p>Every SPI command begins by enabling the chip select pin ([). The first byte is the command to update the DAC (0b00110000), followed by the value to output (255), and a third byte that's ignored (0). The command ends by disabling chip select (]).</p>
<p>We used an 8bit DAC with 255 even voltage steps, output set to 255 is 100%. We can use the Bus Pirate voltage probe to measure the output.</p>
<blockquote><p>SPI&gt;d<strong>&lt;&#8211;measure voltage</strong><br />
9xx VOLTAGE PROBE: 2.5VOLTS<strong>&lt;&#8211;DAC output</strong><br />
SPI&gt;</p></blockquote>
<p>D triggers a voltage measurement. The DAC output voltage is 100% (255/255) of the internal reference, 2.5volts.</p>
<blockquote><p>SPI&gt;[0b00110000 0 0] d<br />
110 SPI CS ENABLED<br />
120 SPI WRITE: 0&#215;30<strong>&lt;&#8211;write DAC command</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;DAC value</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;don&#8217;t care</strong><br />
140 CS DISABLED<br />
9xx VOLTAGE PROBE: 0.0VOLTS<strong>&lt;&#8211;DAC output</strong><br />
SPI&gt;</p></blockquote>
<p>The same command with a DAC value of 0 outputs 0% (0/255) of 2.5volts; 0volts.</p>
<blockquote><p>SPI&gt;[0b00110000 128 0] d<br />
110 SPI CS ENABLED<br />
120 SPI WRITE: 0&#215;30<strong>&lt;&#8211;write DAC command</strong><br />
120 SPI WRITE: 0&#215;80<strong>&lt;&#8211;DAC value</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;don&#8217;t care</strong><br />
140 CS DISABLED<br />
9xx VOLTAGE PROBE: 1.2VOLTS<strong>&lt;&#8211;DAC output</strong><br />
SPI&gt;</p></blockquote>
<p>A DAC value of 128 is about 50% (128/255) of the reference voltage, 1.2volts.</p>
<blockquote><p>SPI&gt;[0b01000000 0 0] d<br />
110 SPI CS ENABLED<br />
120 SPI WRITE: 0&#215;40<strong>&lt;&#8211;power down command</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;don&#8217;t care</strong><br />
120 SPI WRITE: 0&#215;00<strong>&lt;&#8211;don&#8217;t care</strong><br />
140 CS DISABLED<br />
9xx VOLTAGE PROBE: 0.0VOLTS<strong>&lt;&#8211;DAC off</strong><br />
SPI&gt;</p></blockquote>
<p>The LTC2640 has a low power mode, triggered by the command 0b01000000 and two bytes that are ignored. After the power down command we can verify that there&#8217;s output from the DAC. Write any DAC value to exit low power mode.</p>
<p><strong>Taking it further</strong></p>
<p>What&#8217;s the next step for the Bus Pirate? We&#8217;ll eventually make a final update to the design that includes USB on a professionally made, double-sided PCB. Power supply indicator LEDs were slated for this version, but didn&#8217;t get included. It would also be handy to have an AT  keyboard connector for debugging without a PC. Check out the roadmap and wishlists on the <a href="http://hackaday.com/the-bus-pirate-universal-serial-interface/">Hack a Day Bus Pirate page</a>.</p>
<p><strong>Download: <a href="http://blog.mahalo.com/hackaday/howto/buspirate.v1a.zip">buspirate.v1a.zip</a></strong></p>
<br />Posted in hardware, how-to, tool hacks  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/7361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/7361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/7361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/7361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/7361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/7361/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/7361/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/7361/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=7361&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2009/01/22/how-to-bus-pirate-v1-improved-universal-serial-interface/feed/</wfw:commentRss>
		<slash:comments>65</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/front450a.jpg" medium="image">
			<media:title type="html">front450a</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/overview-diagram1.png" medium="image">
			<media:title type="html">overview-diagram1</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/top.jpg" medium="image">
			<media:title type="html">top</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct-450.jpg" medium="image">
			<media:title type="html">cct-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct-pu450.png" medium="image">
			<media:title type="html">cct-pu450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct-vr4.png" medium="image">
			<media:title type="html">cct-vr4</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct-adcin.png" medium="image">
			<media:title type="html">cct-adcin</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/brd450alt.png?w=450" medium="image">
			<media:title type="html">brd450alt</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/cct-pinout450.png" medium="image">
			<media:title type="html">cct-pinout450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/ltc2640.jpg" medium="image">
			<media:title type="html">ltc2640</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2009/01/ltc2640450.png?w=450" medium="image">
			<media:title type="html">ltc2640450</media:title>
		</media:content>
	</item>
		<item>
		<title>How-to: The Bus Pirate, universal serial interface</title>
		<link>http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/</link>
		<comments>http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/#comments</comments>
		<pubDate>Wed, 19 Nov 2008 22:17:57 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[hardware]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[tool hacks]]></category>
		<category><![CDATA[bus]]></category>
		<category><![CDATA[bus pirate]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[debugging tools]]></category>
		<category><![CDATA[eeprom reader]]></category>
		<category><![CDATA[electronics]]></category>
		<category><![CDATA[hacking tools]]></category>
		<category><![CDATA[i2c]]></category>
		<category><![CDATA[ic interface]]></category>
		<category><![CDATA[serial port]]></category>
		<category><![CDATA[spi]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[uart]]></category>

		<guid isPermaLink="false">http://hackadaycom.wordpress.com/?p=5882</guid>
		<description><![CDATA[UPDATE: New firmware with JTAG and more We&#8217;re always excited to get a new chip or SIM card to interface, but our enthusiasm is often dampened by the prototyping process. Interfacing any chip usually means breadboarding a circuit, writing code, and hauling out the programmer; maybe even a prototyping PCB. A few years ago we [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=5882&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-full wp-image-5904" title="i2ceeprom" src="http://hackadaycom.files.wordpress.com/2008/11/i2ceeprom.jpg" alt="i2ceeprom" width="450" height="308" /></p>
<p><strong>UPDATE:</strong> <a href="http://hackaday.com/2008/12/01/bus-pirate-firmware-update-v0c-jtag-and-more/">New firmware with JTAG and more</a></p>
<p>We&#8217;re always excited to get a new chip or SIM card to interface, but our enthusiasm is often dampened by the prototyping process. Interfacing any chip usually means breadboarding a circuit, writing code, and hauling out the programmer; maybe even a prototyping PCB.</p>
<p>A few years ago we built the first &#8216;Bus Pirate&#8217;, a universal bus interface that talks to most chips from a PC serial terminal. Several standard serial protocols are supported at 3.3-5volts, including <a href="http://en.wikipedia.org/wiki/I%C2%B2C">I2C</a>, <a href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">SPI</a>, and <a href="http://en.wikipedia.org/wiki/Asynchronous_start-stop">asynchronous serial</a>. Additional &#8216;raw&#8217; 2- and 3- wire libraries can interface almost any proprietary serial protocols. Since this has been such a useful tool for us, we cleaned up the code, documented the design, and released it here with specs, schematic, and source code.</p>
<p><span id="more-5882"></span></p>
<p><strong>Concept Overview</strong></p>
<p><strong><img class="alignnone size-full wp-image-6028" title="overview-diagram-new" src="http://hackadaycom.files.wordpress.com/2008/11/overview-diagram-new.png" alt="overview-diagram-new" width="450" height="161" /><br />
</strong></p>
<p><strong><br />
</strong></p>
<p>The Bus Pirate is a serial terminal bridge to multiple IC interface protocols. We type commands into a serial terminal on the computer. The commands go to the Bus Pirate through the PC serial port. The Bus Pirate talks to a microchip in the proper protocol, and returns the results to the PC.</p>
<p>All pins output 3.3volts, but are 5volt tolerant. On-board 3.3volt and 5volt power supplies are available to power the connected chip. Software configurable I2C <a href="http://en.wikipedia.org/wiki/Pull-up_resistor">pull-up resistors</a> complete the package.</p>
<p><img class="alignnone size-full wp-image-5893" title="terminal-450" src="http://hackadaycom.files.wordpress.com/2008/11/terminal-450.png" alt="terminal-450" width="401" height="251" /></p>
<p>The serial terminal interface works with any system: PC, Mac, Linux, Palm Pilots, WinCE devices, etc; no crapware required. We considered a USB device, but USB isn&#8217;t compatible with the huge number of hand-held devices that have a serial port. We also wanted a 3.3volt device with 5volt tolerant inputs, but most popular through-hole USB microcontollers were 5volt parts (e.g. the <a href="http://www.microchip.com/ParamChartSearch/chart.aspx?branchID=111&amp;mid=10&amp;lang=en&amp;pageId=74">PIC18Fx550</a>).</p>
<p>The Bus Pirate currently &#8216;speaks&#8217; three hardware protocols for high-speed interfacing, and has two software protocol libraries for easy bus manipulation. The theory and specification of each protocol is beyond what we can cover here, but check out some of these tutorials:</p>
<p><em>I2C</em></p>
<p>A slow 2 wire bus. Wikipedia is a great place to start for <a href="http://en.wikipedia.org/wiki/I%C2%B2C">I2C background</a>. <a href="http://www.i2c-bus.org/">I2C-Bus.org</a>, <a href="http://www.robot-electronics.co.uk/htm/using_the_i2c_bus.htm">Robot Electronics</a>, <a href="http://www.esacademy.com/faq/i2c/">Embedded Systems Academy</a>, and <a href="http://www.embedded.com/story/OEG20010718S0073">Embedded.com</a> have decent I2C tutorials.</p>
<p><em>SPI</em></p>
<p>A simple 3 wire bus. Wikipedia has <a href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">background</a>; Embedded.com has a great <a href="http://www.embedded.com/columns/beginerscorner/9900483">tutorial and comparison to I2C</a>.</p>
<p><em>Universal Asynchronous Receiver Transmitter (UART or serial)</em></p>
<p>A clock and timing dependent serial protocol best known for its appearance as the PC serial port protocol. Wikipedia has background on <a href="http://en.wikipedia.org/wiki/Asynchronous_start-stop">asynchronous serial protocols</a>.</p>
<p><em>Raw 2 wire</em></p>
<p>This is a generic 2 wire protocol library, similar to I2C but without an ACK bit. I2C and many proprietary 2 wire protocols can be formed using the bus manipulations available in this mode. Use this library to work with non-I2C 2 wire devices, like <a href="http://www.smartcardsupply.com/Content/Cards/SLE4442.htm">smartcards</a> or <a href="http://www.sensirion.com/en/01_humidity_sensors/02_humidity_sensor_sht11.htm">Sensirion SHT11</a> temperature/humidity sensors.</p>
<p><em>Raw 3 wire</em></p>
<p>This is a generic 3 wire protocol library, similar to SPI but without the constraints of a hardware module. Use this library to work with devices that use non-8bit compatible 3-wire protocols, like the <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=569">Sparkfun Nokia 6100 LCD knock-off</a>. Many 3 wire protocols can be formed using the bus manipulations available in this mode.</p>
<p><strong>Hardware</strong></p>
<p><img class="alignnone size-full wp-image-5897" title="brd-450" src="http://hackadaycom.files.wordpress.com/2008/11/brd-450.png" alt="brd-450" width="451" height="325" /></p>
<p><a href="http://hackadaycom.files.wordpress.com/2008/11/brd.png">Click for a full size PCB placement image</a> (PNG). Screw terminals connect to the power supplies. A row of seven pin headers connect to the IO pins. Despite the label, only 7volts DC is required.</p>
<table style="text-align:left;" border="0">
<tbody>
<tr>
<td>
<div><strong>PIN</strong></div>
</td>
<td>
<div><strong>SPI</strong></div>
</td>
<td>
<div><strong>I2C</strong></div>
</td>
<td>
<div><strong>RS232</strong></div>
</td>
</tr>
<tr>
<td>
<div><strong>B9</strong></div>
</td>
<td>
<div>MOSI</div>
</td>
<td>
<div>SDA</div>
</td>
<td>
<div>-</div>
</td>
</tr>
<tr>
<td>
<div><strong>B8</strong></div>
</td>
<td>
<div>CLK</div>
</td>
<td>
<div>SCL</div>
</td>
<td>
<div>-</div>
</td>
</tr>
<tr>
<td>
<div><strong>B7</strong></div>
</td>
<td>
<div>MISO</div>
</td>
<td>
<div>-</div>
</td>
<td>
<div>RX</div>
</td>
</tr>
<tr>
<td>
<div><strong>B6</strong></div>
</td>
<td>
<div>CS</div>
</td>
<td>
<div>-</div>
</td>
<td>
<div>TX</div>
</td>
</tr>
<tr>
<td>
<div><strong>B5</strong></div>
</td>
<td>
<div>AUX</div>
</td>
<td>
<div>AUX</div>
</td>
<td>
<div>AUX</div>
</td>
</tr>
<tr>
<td>
<div><strong>Ground</strong></div>
</td>
<td>
<div>GND</div>
</td>
<td>
<div>GND</div>
</td>
<td>
<div>GND</div>
</td>
</tr>
</tbody>
</table>
<p>This table shows the pin connections for each bus mode. Raw 2 wire mode uses the same pin configuration as I2C. Raw 3 wire mode uses the same pin configuration as SPI.</p>
<p><img class="alignnone size-full wp-image-5899" title="cct-450" src="http://hackadaycom.files.wordpress.com/2008/11/cct-450.png" alt="cct-450" width="450" height="191" /></p>
<p><a href="http://hackadaycom.files.wordpress.com/2008/11/cct.png">Click for a full size circuit image</a> (PNG). The circuit and PCB are designed using the freeware version of <a href="http://www.cadsoft.de">Cadsoft Eagle</a>. Download the <a href="http://blog.mahalo.com/hackaday/howto/buspirate.v0b.zip">project archive</a> (ZIP).</p>
<p><em>PIC 24FJ64GA002</em></p>
<p>We used a <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en026374">PIC24FJ64GA002</a> microcontroller in the Bus Pirate; this is the same chip we used in our <a href="http://hackaday.com/2008/09/25/web-server-on-a-business-card-part-2/">mini-server project</a>. It&#8217;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. Each power pin needs a decoupling capacitor(C12,13), and the MCLR function requires a resistor (R7) between pin 1 and 3.3volts. The PIC has an internal voltage regulator that requires a 10uF tantalum capacitor (C3), though we used a plain electrolytic capacitor without issue. Read about programming and working with this chip in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">PIC24F tutorial</a>. If you don&#8217;t have a PIC debugger, several readers recommend the under-$40 ICD2 clones on eBay.</p>
<p>The PIC runs at 3.3volts, but the digital-only pins are 5volt tolerant for interfacing 5volt logic. Pins 14,15,16,17,18,21, and 22, are digital only, which we determined by looking through the datasheet and eliminating any pins with an analog connection type (table 1-2, pages 11-16). According to the datasheet, I2C pins are also 5volt tolerant. There&#8217;s a bunch of conflicting information on the web, but datasheet page 230, parameter DI28, clearly states that the max input for a 24FJ64GA002 I2C pin without analog circuitry is 5.5volts.</p>
<p>Pins 21 and 22 (RB10/11) can pull-up SDA/SCL through resistors R4 and R5.</p>
<p><em>MAX3223CPP</em></p>
<p>This chip converts 3.3volt serial output to +/-10volt RS232 signals compatible with a PC serial port. The MAX3223CPP is a 3-5volt version of the MAX202, with extra power saving features. MAX RS232 transceivers require four 0.1uF capacitors for a charge pump (C4,5,7,8), and one decoupling capacitor (C17). We used the same capacitors for everything.</p>
<p>We used a MAX3223CPP, which doesn&#8217;t seem to be available anymore. <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=MAX3223EEPP%2B-ND">MAX3223EEPP+</a> is a pin-compatible newer version, available at Digikey for $7. Ouch! None of the 3223&#8242;s power saving features are used, so a cheaper, simpler 3.3volt RS232 transceiver should be substituted if at all possible.</p>
<p><em>Power supplies</em></p>
<p>Most chips can be powered from the Bus Pirate&#8217;s on-board 3.3volt and 5volt supplies. 5volts is supplied by a common 7805 regulator (VR2) and two decoupling capacitors (C9,10). An LM317 adjustable regulator (VR1) is set to 3.3volts using two resistors (R2,3), and requires two decoupling capacitors (C6,7). The circuit requires a 7-10volt DC supply (J1).</p>
<p><em>Part list</em></p>
<table style="text-align:left;" border="0">
<tbody>
<tr>
<td><strong>Part </strong></td>
<td><strong>Value</strong></td>
</tr>
<tr>
<td>IC1</td>
<td><a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=PIC24FJ64GA002-I/SP-ND">PIC24FJ64GA002-DIP</a></td>
</tr>
<tr>
<td>IC2</td>
<td>MAX3223CPP (try <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail?name=MAX3223EEPP%2B-ND">MAX3223EEPP+</a>)</td>
</tr>
<tr>
<td>C3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=M%252b5JCWh%252b1ty3RFguvdcdsg%3d%3d">10uF capacitor</a> (preferably tantalum)</td>
</tr>
<tr>
<td>C4-13,17</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=9AX3phJxokWIpR5WRGtIJw%3d%3d">0.1uF capacitors</a></td>
</tr>
<tr>
<td>R1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=ULgY8XwKjTmmv2gtdH4CoQ%3d%3d">330 ohm resistor</a></td>
</tr>
<tr>
<td>R2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=4eNa8160l8VHA9lUHkRdvw%3d%3d">240 ohm resistor</a></td>
</tr>
<tr>
<td>R3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=X3IDIfI%252bJAVuAq1Yim8fmg%3d%3d">390 ohm resistor</a></td>
</tr>
<tr>
<td>R4,5,7</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=8tsW7z%2fc78pkoLNVKn1xoQ%3d%3d">2K2  ohm resistor</a></td>
</tr>
<tr>
<td>VR1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=swDD%252bF%252bps7c8uLyY%252b3mJJw%3d%3d">LM317</a></td>
</tr>
<tr>
<td>VR2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=cnIeywgme7bzmZ37%2fiFT9w%3d%3d">LM7805</a></td>
</tr>
<tr>
<td>X1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=wjes1ZhMGKfGv3iS94oZ%252bQ%3d%3d">Screw clamp (3 terminals)</a> *untested</td>
</tr>
<tr>
<td>X2</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=nAEW9fCjKd%2fyLNwP2ItddQ%3d%3d">DB9 Female connector (serial port)</a> *untested</td>
</tr>
<tr>
<td>ICSP,SV3</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?R=4-103329-0virtualkey57100000virtualkey571-41033290">.1&#8243; pin header, right angle</a></td>
</tr>
<tr>
<td>J1</td>
<td><a href="http://www.mouser.com/Search/ProductDetail.aspx?qs=8xMK%252bwDsXhcfMNb%2fYnnwLQ%3d%3d">Power jack, 2.1mm pin</a></td>
</tr>
<tr>
<td>LED1</td>
<td>3mm LED (optional)</td>
</tr>
</tbody>
</table>
<p><strong>Firmware</strong></p>
<p>The firmware is written in C using the free demonstration version of the <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en010065">PIC C30 compiler</a>. Learn all about working with this PIC in our <a href="http://hackaday.com/2008/09/18/web-server-on-a-business-card-part-1/">introduction to the PIC 24F series</a>. Download the <a href="http://blog.mahalo.com/hackaday/howto/buspirate.v0b.zip">project archive</a> (ZIP).</p>
<p>main.c &#8211; Handles the user terminal interface.</p>
<p>busPirate.c &#8211; Abstraction routines that convert syntax to actions on the proper bus.</p>
<p>uartIO.c &#8211; IO routines for both hardware UARTs.</p>
<p>m_i2c_1.c &#8211; Software I2C routines by [<a href="http://www.microchipc.com/sourcecode/#i2c">Michael Pearce</a>]. We couldn&#8217;t get the PIC hardware I2C to work, so we used this helpful library. The software doesn&#8217;t take into account the I2C speed setting, and seems to work at about 5KHz.</p>
<p>SPI.c &#8211; Routines that drive the hardware SPI module.</p>
<p>raw2wire.c &#8211; Software 2-wire interface library.</p>
<p>raw3wire.c &#8211; Software 3-wire (SPI) interface library.</p>
<p>User input is held in a 4000 byte buffer until a newline character (enter) is detected. If the first character of the input is a menu option (see below), the menu dialog is shown, otherwise the string is parsed for data to send over the bus (see syntax). The code consists of an embarrassing number of switch statements and spaghetti code.</p>
<p><strong>Terminal interface</strong></p>
<p>Rather than write a junk piece of software to control the device, we gave it a serial command line interface that will work with any ASCII terminal.  The bus pirate responds to commands with three digit result codes and a short message. The codes are designed with PC automation in mind. We&#8217;ve included a table of result codes in the <a href="http://blog.mahalo.com/hackaday/howto/buspirate.v0b.zip">project archive</a> (zip).</p>
<p><em>Menu options</em></p>
<p>Menu options are single character commands that don&#8217;t involve data transfers. Enter the character, followed by &lt;enter&gt;, to access the menu.</p>
<p><strong>?</strong> &#8211; Show a help menu with commands and syntax.</p>
<p><strong>M</strong> &#8211; Set the bus mode (SPI, I2C, UART, raw 2 wire, raw 3 wire). Followed immediately by a prompt for speed, polarity, and output state (mode dependent).</p>
<ul>
<li>Bus speeds: SPI:30, 125, 250, 1000KHz. I2C:100, 400, 1000KHz. UART: 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200bps. Raw modes: 1, 10, 50KHz.</li>
<li>Inverse clock setting sets the idle state opposite of normal (normal SPI:idle low; normal UART:idle high): SPI:idle high; UART:idle low.</li>
<li>Some modes have optional high-z output modes for use with pull-up resistors (Low=ground, High=input).</li>
</ul>
<p><strong>L &#8211; </strong>Toggle bit transmit/receive order: most/least significant bit first.</p>
<p><strong>P</strong> &#8211; SDA/SCL pin pull-up resistor toggle (3.3volts). Only valid in I2C and raw 2 wire modes.</p>
<p><strong>O</strong> &#8211; Set number output display format. The terminal can display numbers as decimal, hexadecimal, and binary ASCII values. A fourth format sends the raw, unprocessed byte for reading ASCII formatted text.</p>
<p><em>Syntax</em></p>
<p>A simple syntax is used to communicate with chips over a bus.  Syntax commands have generic functions that generally apply to all bus types.</p>
<p><strong>A/a/@ </strong> &#8211; Toggle auxiliary pin. Capital &#8220;A&#8221; sets AUX high, small &#8220;a&#8221; sets to ground. @ sets aux to input (high impedance mode) and reads the pin value.</p>
<p><strong>[ </strong> - Start data write. SPI/raw 3 wire: chip select enabled. I2C/raw 2 wire: start condition. RS232: open UART, discard received bytes.</p>
<p><strong>{ </strong> - Start data write with reads. Same as [, except: SPI/raw 3 wire: show the read byte for each write. RS232: display data as it arrives asynchronously.</p>
<p><strong>] or }</strong> &#8211; End data write. SPI/raw 3 wire: chip select disabled. I2C/raw 2 wire: stop condition. RS232: close UART.</p>
<p><strong>R/r</strong> &#8211; Read byte. SPI/raw 3 wire: send dummy byte, return read. I2C: read byte with ACK. Raw 2 wire: read 8 bits. RS232: check UART for byte and return, or fail if empty. Use 0r1&#8230;255 for bulk reads up to 255 bytes.</p>
<p><strong>0b</strong> &#8211; Write this binary value. Format is 0b00000000 for a byte, but partial bytes are also fine: 0b1001.</p>
<p><strong>0h or 0x</strong> &#8211; Write this HEX value. Format is 0h01 or 0&#215;01. Partial bytes are fine: 0xA. A-F can be lower-case or capital letters.</p>
<p><strong>0-255</strong> &#8211; Write this decimal value. Any number not preceded by 0x, 0h, or 0b is interpreted as a decimal value.</p>
<p><strong>, or space</strong> -	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}.</p>
<p><em>Direct bus manipulation commands for raw 2 wire mode and raw 3 wire mode.</em><br />
<strong>^</strong> &#8211; Send one clock tick. Use 0^1&#8230;255 for multiple clock ticks.</p>
<p><strong>/ and \</strong> &#8211; Toggle clock level high (/) and low (\). Includes clock delay (100uS).</p>
<p><strong>-/_</strong> &#8211; Toggle data state high (-) and low (_). Includes data setup delay (20uS).</p>
<p><strong>! </strong>- Read one bit with clock.</p>
<p><strong>. </strong>- Read data pin state (no clock).</p>
<p><strong>&amp;</strong> &#8211; Delay 1uS. Use 0&amp;1&#8230;255 for multiple delays.</p>
<p><strong>Using it</strong></p>
<p><strong><img class="alignnone size-full wp-image-5902" title="buspirate-24fv0a" src="http://hackadaycom.files.wordpress.com/2008/11/buspirate-24fv0a.jpg" alt="buspirate-24fv0a" width="450" height="330" /><br />
</strong></p>
<p>Here are two examples that show the Bus Pirate in action. Terminals should be set to ASCII mode with local echo, we used the Windows serial terminal. The PC-side serial connection is 115200bps, 8N1. The Bus Pirate should respond to any single line feed type (0x0a, 0x0d), or both (Windows style).</p>
<p><em><a name="EEPROM">.</a>I2C/SPI &#8211; Flash 24LC1025 EEPROM</em></p>
<p><a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=80">Microchip&#8217;s EEPROMS</a> are popular permanent-storage memory chips, the <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en024636">24LC1025</a> has 128Kbytes of storage with an I2C interface.  We can test this chip without bread-boarding a big circuit or writing code.</p>
<p><img class="alignnone size-full wp-image-5904" title="i2ceeprom" src="http://hackadaycom.files.wordpress.com/2008/11/i2ceeprom.jpg" alt="i2ceeprom" width="450" height="308" /></p>
<p>The picture shows an 24LC1025 connected to the Bus Pirate. The EEPROM works from 2.7 to 5volts, so we used the 3.3volt supply from the Bus Pirate to power the circuit. The on-board SDA/SCL pull-up resistors hold the I2C bus high, and eliminate the need for external resistors. A single 0.1uF capacitor decouples the EEPROM from the power supply.</p>
<p><span style="text-decoration:underline;">Setup I2C mode</span></p>
<p>First, we setup the Bus Pirate for I2C mode and enable the pull-up resistors. Since the Bus Pirate currently uses a software I2C library, the speed setting doesn&#8217;t really have an effect.</p>
<blockquote><p>SPI&gt;m  <strong>&lt;&#8211;enter m for mode select</strong><br />
1. SPI<br />
2. I2C<br />
3. UART<br />
4. RAW 2 WIRE<br />
5. RAW 3 WIRE<br />
MODE&gt;2  <strong>&lt;&#8211;enter 2 for I2C</strong><br />
900 MODE SET<br />
Set speed:<br />
1. 100KHz (Standard)<br />
2. 400KHz (Fast Mode)<br />
3. 1MHz (High Speed)<br />
SPEED&gt;1 <strong>&lt;&#8211;speed doesn&#8217;t really do anything&#8230;</strong><br />
901 SPEED SET<br />
202 I2C READY, P/p FOR PULLUPS<br />
I2C&gt;P   <strong>&lt;&#8211;enable the I2C pull-up resistors</strong><br />
205 I2C PULLUP ON<br />
I2C&gt;</p></blockquote>
<p><span style="text-decoration:underline;">Write to EEPROM (I2C)</span></p>
<p>All I2C operations begin with a start condition { or [, and end with a stop condition } or ]. A write begins by addressing the device (1 byte) and looking for an acknowledgment bit (ACK). If the EEPROM responds, we can send the data location to write (2 bytes) and data payload (n bytes). The Bus Pirate automatically checks for an ACK at the end of each write, and ACKs each read.</p>
<p>The 24LC1025 base address is 1010xxy, where xx is determined by the state of pins 2 and 3, and y is read (1) or write (0) mode. We tied pins 2 and 3 high, making the full write address <strong>1010110</strong>.  We&#8217;ll start writing to the device at the first data location (<em>0 0</em>), and write one to thirteen using a mix of data input formats (<span style="text-decoration:underline;">1&#8230;13</span>).</p>
<blockquote><p>I2C&gt;{<strong>0b10100110 </strong><em>0 0 </em><span style="text-decoration:underline;">1 2 3 4 5 6 7 8 9 10 0xb 0xc 13</span>} <strong>&lt;&#8211;I2C command </strong><br />
210 I2C START CONDITION <strong>&lt;&#8211;bus start</strong><br />
220 I2C WRITE: 0xA6 GOT ACK: YES <strong>&lt;&#8211;address sent and ACK received</strong><br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES <strong>&lt;&#8211;write address</strong><br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES <strong>&lt;&#8211;write address</strong><br />
220 I2C WRITE: 0&#215;01 GOT ACK: YES <strong>&lt;&#8211;data</strong><br />
&#8230;<br />
220 I2C WRITE: 0x0D GOT ACK: YES<br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p><span style="text-decoration:underline;">Read from EEPROM (I2C)</span></p>
<p>Reading the 24LC1025 takes two steps. First, a write command with no data sets the address pointer. Second, a read command outputs data starting at the location set in step 1.</p>
<p>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 address pointer is set to the location where we wrote our data (0 0).</p>
<blockquote><p>I2C&gt;{0xa6 0 0} <strong>&lt;&#8211;set write pointer command</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0xA6 GOT ACK: YES<br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES<br />
220 I2C WRITE: 0&#215;00 GOT ACK: YES<br />
240 I2C STOP CONDITION</p></blockquote>
<p>With the pointer set, we can start reading data. The read address is the device address, with the last bit set to 1 ( 0b10100111 or 0xa7). We used thirteen r commands to read the data, but we could have used the shorthand version: 0r13.</p>
<blockquote><p>I2C&gt;{0b10100111 rrrrrrrrrrrrr}<strong> &lt;&#8211;read command</strong><br />
210 I2C START CONDITION<br />
220 I2C WRITE: 0xA7 GOT ACK: YES <strong>&lt;&#8211;chip ACKed the read address</strong><br />
230 I2C READ: 0&#215;01 <strong>&lt;&#8211;data byte 1</strong><br />
230 I2C READ: 0&#215;02 <strong>&lt;&#8211;data byte 2</strong><br />
&#8230;<br />
230 I2C READ: 0x0D <strong>&lt;&#8211;data byte 13</strong><br />
240 I2C STOP CONDITION<br />
I2C&gt;</p></blockquote>
<p>We know the operation was a success because the output matches the data we wrote earlier.</p>
<p><em>UART &#8211; EM406 SurfIII GPS</em></p>
<p><img class="alignnone size-full wp-image-5905" title="gps" src="http://hackadaycom.files.wordpress.com/2008/11/gps.jpg" alt="gps" width="450" height="338" /></p>
<p>The <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=465">EM406</a> is a tiny 5volt GPS module that tracks up to 20 satellites. By default, it outputs NMEA formatted data from a serial port at 4800bps, 8N1. The output format is standard serial, but at 2.8volts it&#8217;s incompatible with PC serial ports. The Bus Pirate can interface this GPS without the need for a separate RS232 transceiver or 5volt power supply.</p>
<p><span style="text-decoration:underline;">Setup the UART</span></p>
<p>First, we setup the Bus Pirate UART to receive serial data at 4800bps.</p>
<blockquote><p>I2C&gt;m <strong>&lt;&#8211;setup mode</strong><br />
1. SPI<br />
2. I2C<br />
3. UART<br />
4. RAW 2 WIRE<br />
5. RAW 3 WIRE<br />
MODE&gt;3 <strong>&lt;&#8211;UART</strong><br />
900 MODE SET<br />
Set speed:<br />
(bps)<br />
1. 300<br />
2. 1200<br />
3. 2400<br />
4. 4800<br />
&#8230;<br />
9. 115200<br />
SPEED&gt;4  <strong>&lt;&#8211;4800bps</strong><br />
901 SPEED SET<br />
302 UART READY<br />
UART&gt;</p></blockquote>
<p><span style="text-decoration:underline;">Enable UART and data reads</span></p>
<p>An important thing to remember about UARTs is that the data arrives asynchronously. Unlike SPI and I2C, where data transfer is controlled by the master, serial data can arrive at the UART at any time. The GPS is a great example of this because it spits out location data continuously, without user intervention.</p>
<p>We developed two read modes to cope with asynchronous data .  { echos all incoming data as it arrives.  New data will displace and garble data entry, but all input is still accepted normally.  [ opens the UART in a send only mode that discards incoming bytes. } or ] closes the UART, regardless of the mode.</p>
<blockquote><p>UART&gt;{ <strong>&lt;&#8211;open UART with async reads</strong><br />
310 UART OPEN, } TO CLOSE<br />
330 UART READ: 0&#215;80 <strong>&lt;&#8211;GPS data</strong><br />
330 UART READ: 0&#215;78</p></blockquote>
<p><span style="text-decoration:underline;">Write to the UART</span></p>
<p>Type in values to send out the UART. Even if the input is broken up by incoming data, it will be processed on &lt;enter&gt;.  We sent <em>0&#215;40</em> as an example, but this has no particular meaning to the GPS module.</p>
<blockquote><p>330 UART READ: 0&#215;80 <em>0&#215;40</em><strong>&lt;&#8211;random byte to write</strong><br />
320 UART WRITE: 0&#215;40 <strong>&lt;&#8211;byte written</strong></p></blockquote>
<p><span style="text-decoration:underline;">Close the UART</span></p>
<p>&#8220;}&#8221; followed by &lt;enter&gt; closes the UART.</p>
<blockquote><p>330 UART READ: 0&#215;78<br />
303 UART READ: 0&#215;60 <em>} </em><strong>&lt;&#8211;close UART command</strong><br />
330 UART READ: 0xE6<br />
340 UART CLOSED<br />
UART&gt;</p></blockquote>
<p>Don&#8217;t think you can use this GPS data to track us, we don&#8217;t actually get satellite reception down here in mom&#8217;s basement.</p>
<p><strong>Taking it further</strong></p>
<p>The Bus Pirate is an important development tool in our lab. We keep updating it as we use it, and we&#8217;ll release new firmware as we add protocols and features. Expect to see the Bus Pirate in future articles.</p>
<p>These improvements are at the top of our list. Do you have any suggestions?</p>
<ul>
<li>New protocols: One Wire, CAN, ???</li>
<li>Controls for polarity and other settings</li>
<li>Adjustable instruction delay</li>
<li>Get hardware I2C module working.</li>
<li>Enable protocol speed settings.</li>
<li>Cheaper, easier to get RS232 transceiver</li>
</ul>
<p>The <a href="http://blog.mahalo.com/hackaday/howto/buspirate.v0b.zip">project archive</a> (ZIP) has everything you need to build your own Bus Pirate.</p>
<br />Posted in hardware, how-to, tool hacks  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/hackadaycom.wordpress.com/5882/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/hackadaycom.wordpress.com/5882/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/hackadaycom.wordpress.com/5882/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/hackadaycom.wordpress.com/5882/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/hackadaycom.wordpress.com/5882/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/hackadaycom.wordpress.com/5882/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/hackadaycom.wordpress.com/5882/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/hackadaycom.wordpress.com/5882/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=hackaday.com&amp;blog=4779443&amp;post=5882&amp;subd=hackadaycom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://hackaday.com/2008/11/19/how-to-the-bus-pirate-universal-serial-interface/feed/</wfw:commentRss>
		<slash:comments>54</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Ian</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/i2ceeprom.jpg" medium="image">
			<media:title type="html">i2ceeprom</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/overview-diagram-new.png" medium="image">
			<media:title type="html">overview-diagram-new</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/terminal-450.png" medium="image">
			<media:title type="html">terminal-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/brd-450.png" medium="image">
			<media:title type="html">brd-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/cct-450.png" medium="image">
			<media:title type="html">cct-450</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/buspirate-24fv0a.jpg" medium="image">
			<media:title type="html">buspirate-24fv0a</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/i2ceeprom.jpg" medium="image">
			<media:title type="html">i2ceeprom</media:title>
		</media:content>

		<media:content url="http://hackadaycom.files.wordpress.com/2008/11/gps.jpg" medium="image">
			<media:title type="html">gps</media:title>
		</media:content>
	</item>
	</channel>
</rss>
