AirBorn Electronics

2 Wire Input/Output for 8051 type CPU's

When using single chip micro's, especially the smaller single chip micro's like the AT89C2051, it is often desirable to expand the I/O serially.

One good method of serial expansion, practised widely, is the use of the i2c bus. The i2c bus is versatile, and needs only two wires for communication, but unfortunately the parts are a little expensive. If you need the versatility of being able to add not only parallel I/O, but devices like EEPROM, RAM and clocks, then the i2c bus is for you, and you should refer to the excellent application note from Atmel, or the full information from Philips, concerning this approach.

Sometimes cost and simplicity are more important than versatility. The simplest form of I/O expansion uses shift registers. To put this in dollar terms, the cost of implementing an 8 bit I/O port in i2c technology is around the $3 mark, while in shift register logic it is around 0.75c. Also, if required, 4094 shift register outputs can be tri-stated at power up until the CPU has written valid data, preventing power up "glitches"

8051logo

Shift registers can be cascaded as required, and the software to input and output is quite simple. Four I/O pins can be a lot to lose, however. For the cost of a few passive components the arrangement shown implements 2 wire I/O for an 8051 using shift registers.

Schematic of the 2 wire COMs

The circuit as shown requires that the software access be performed in a certain way

Circuit Library The first set of inputs read after reset will not be correct, as no strobe pulse was generated to load the registers, however they must be read, as otherwise it is not possible to load the outputs with valid data. The outputs can be held in the "off" state after reset by controlling them with the OE line on the CD4094, if desired. While the OE lines to the CD4094's are held low, the outputs will be tristate. So at reset, the procedure should be to do a dummy read of all the inputs, then start normal output/input cycles, and enable the outputs by setting the OE line of the CD4094's high.

For explanation purposes, it was necessary to show the driver software above doing input, output, then strobe. However, for implementation purposes, it may be more desirable to do the software as output, strobe, then input. As long as the dummy inputs are done at power up, this is the same operation stated a different way. The advantage of performing the operation as output, strobe, input, is that the latest input values are read, no matter how long ago the last I/O operation occurred.


--AirBorn Electronics--Contact Info Return to Home Subject Overview Subject Continue Bye
©2008 AirBorn