circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

Issue 140 March 2002
Spy-Size Event Logger

 


byJeff Bachiochi

I2C for your UART

I used to be able to do a few basic auto repairs. Many of those now require special tools. It’s unfair practice to design in the requirement for a special tool that ends up costing more than the repair itself. If you were concerned about the same problem when I mentioned I2C, don’t worry, I won’t let you down.

Let’s take a short break from the DS1678 and develop an I2C interface for your serial port. I picked up one of my favorite micros, the PIC16F84, PicBasic Pro, and threw together a serial-to-I2C interface (see Figure 2). With PicBasic Pro I can configure a software UART with four user-selectable data rates in the ’F84. I can even have programmable serial polarity to eliminate level shifters (this inverted TTL interface works fine with most serial ports). Also in the PicBasic Pro’s vocabulary is an I2C interface, which can be defined on any I/O pins just like the software UART.

Figure 2—This circuit allows a dumb terminal (or smart application) to access I2C devices via a serial connection. Note the use of a MAX680 to steal power from the serial port.

The application handles the four basic I2C routines, read, write, and registered read and write. Asynchronous serial communication (on one side) asks you whether the action will be writing or reading and whether the read or write is registered. Your reply will direct the questions toward collecting the device’s address, register number (if necessary), and data. This mini project then creates an I2C communication (on the other side) to communicate on its two-wire, open-collector I2C bus. A reply is generated on the serial port and the cycle can be repeated. With these basic routines you should be able to communicate with any I2C device tied to its bus.