Using an 8255 PPI chip

Well I had the hardest time getting one of this chips to work so I thought I'd post some information on how to use the chip (namely what I was doing wrong).

When working with these chips it is very handy to have a white paper (data sheet) in your hand:

8255A.PDF

 

Mode 0

Since my application was working with all outputs, I'll assume we're going to work in Mode 0. The basic steps needed to get one of these chips initialized are:

  1. power on
  2. reset the 8255 using the RESET pin
  3. set the write pin (WR) high
  4. put the control word on the data bus (selects the Mode)
  5. set A0 and A1 pins high
  6. set the write pin (WR) low for a very short duration, keeping A0 & A1 high
  7. set the write pin (WR) high again

When step seven happens, it causes the chip to "take note" of the data bus and pins A0 & A1. When both of the Ax pins are high, the 8255 knows that the data present on the data bus is a control word and from that data, it goes into the appropriate mode. You only have to do the above seven steps once (on power up), unless one wishes to reset the chip during operation. Then just start from step 2 (since you already have power to the chip). Please note that when an 8255 is reset, all three of it's ports go into input mode.

Now that the chip is initialized, the steps to use it are as follows:

  1. set A0 & A1 to what 8255 port (A, B, or C) you want to work with
  2. make the data bus look like what you want the 8255 port you're working with to look like (highs and lows)
  3. set the write pin (WR) low for a very short duration
  4. set the write pin (WR) high again
  5. go back to step one

Please note that we are assuming 8255 mode 0 here (all three 8255 ports are outputs). One needs to keep the write pin (WR) high at all times until you're ready to "program" the chip. This is where I messed up. I left WR high all the time, assuming that would keep the 8255 in 'write' mode. It needs to go from high to low and back to high in order to 'program' the chip.

 

Mode 1

Editor's note:  The following information is courtesy of Melt Brink (pbrink@fnb.co.za)

"I managed to the get port B configured for a input port.  It acts exactly like the other two ports as far as I could see.  Here's the trick - when A0 and A1 are applied the write pin (WR) should be toggled low (high-low-high) to initialize the port.  When reading from a port the write pin (WR) should remain high and the read pin (RD) should be toggled (high-low-high).

"I have found it easier to write two subroutines which I call in my program.  One toggles the write pin (WR) keeping the read pin (RD) high (thus putting data from the data bus into the 8255 and onto the selected 8255 port).  The other subroutine toggles the read pin (RD) keeping the write pin (WR) high (this allows you to read from the selected 8255 port via data bus).

"The important thing to remember is to keep the control line you are not using high.  I assume the other two ports will be configured the same way.  It works really well and I was surprised how simple it was after I played around a bit."

-Melt Brink

So to use this information first initialize the 8255 to the Mode you want it to be in.  Next use the following steps to read data from the chip:

  1. set A0 & A1 to what 8255 port (A, B, or C) you want to work with
  2. set the read pin (RD) low for a very short duration
  3. set the read pin (RD) high again
  4. note the data on the data bus
  5. go back to step one

 

Return to Electronic Projects page

Return to HOME, Dorothy!

Created on 3/31/98 / Last modified on 09/21/00
by Drew Hickman / drew@hickmans.net