Testing the 74HC299 data bus interface

I wired the 74HC299 onto a solderless bread-board along with my TEENSY 2.0++ running AttoBASIC V2.34 and a CD4511 driven 7-segment display connected to the outputs of the 74HC299. [Note: I am the maintainer of AttoBASIC since 2011.  Only V2.32 is currently available at this time but V2.34 will be available soon]  AttoBASIC makes a great development platform to test interface and operation of various devices while evaluating them. It beats repeated writing, debugging and downloading of code into the AVR.  Once again, I found it instrumental in accomplishing the task at hand.

74hc299_connections
74HC299 Connections

Reading the datasheet can be a little confusing with regards to determining proper operation as a bidirectional parallel-to-serial and serial-to-parallel device. Since I am out of full 8-bit I/O ports on the AT90USB1286, this seemed the way to go and it comes in a 20-pin DIP or a 20-pin SOIC package. DIP for testing and SOIC on the PCB.

Using the AVR’s SPI in “mode 2” and setting the OE’s and S1 low achieved the output function on the first try.  After fiddling to find the right combinations of the states of S1 and OE, I was able to get my test code to work.

In short, the sequence is as follows:

Sequence to read from the bus;

  1. Set S1=1 and OE=1
  2. Perform a dummy SPI write (toggles the CLK line to load the registers with the state of the I[7..0] pins)
  3. Set S1=0 to enable bit right shifting
  4. Read data from the bus with an SPI read
  5. Set S1=1 to end the bus read.

Sequence to write data to the bus;

  1. Set S1=0 and OE=1 to enable bit right shifting
  2. Perform an SPI write with the desired data
  3. Set OE=0 to enable the output drivers
  4. Set S1=1 and OE=1 to end the bus write and tri-state the pin drivers.
The AttoBASIC test code is as follows:
  10 REM 74HC299 TEST
  15 SDC7; SBC7 # OE=1 -> HI-Z
  20 SBC6; SDC6 # (S0=1) S1=1 -> READ DATA
  25 SPM 2 # SPI TO MODE 2
  30 FOR N=0 15 # LOOP DIGIT TO DISPLAY
  35 GOSUB 55 # WRITE TO BUS
  40 GOSUB 65 # READ FROM BUS
  45 NEXT; SPS # CONTINUE LOOP, SET "SS" HIGH WHEN FINISHED 
  50 END # END PROGRAM
  55 CBC6; CBC7; PRI "N="; PRI N; SPW N # S1=0 -> SHIFT RIGHT OE=0 -> OUT TO BUS
  60 SLP4; SBC6; SBC7; RETURN # WAIT, S1=1, OE=1 THEN RETURN
  65 SPW 0; CBC6; PRI "DATA: "; PRX SPR; SBC6; RETURN #DUMMY WRITE, S1=0, PRINT BUS DATA, S1=1 THEN RETURN

Time spent on this phase of the project was less than an hour.

Next up; determine if the AVR can emulate an 82C55A PIO.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s