io. wrote:
brad wrote:
What you need is a way to expand your output ports.
The best way to do this (in my experience) is to get some 74373 chips.
They are 8-bit data latches with tri-state outputs.
What you can do with these is get three of them. connect the eight inputs of each one to PORTB of your microcontroller (so they all have exactly the same inputs)
Then connect the eight outputs of each chip to your eight red cathodes, your eight green cathodes and then your eight anodes. (one chip for each section)
Then, connect the latch enable pin of each chip to one of the pins on PORTA. So you could connect the latch enable of the red 74373 to PORTA pin 0, then green latch enable to PORTA pin 1 and then the anode latch enable to PORTA pin 2.
Then lastly, the 74373 chips have an output enable pin (because they have tri-state outputs) so you need to connect all three output enable pins of the three chips together, and then to PORTA pin 3.
So, to draw an image you need to send out three bytes of data (one for the red cathodes, one for green and one for the anodes. First send the red byte to PORTB, then enable the red 74373 latch by making PORTA pin 0 a logic 1, then 0 again. Then send the green byte to PORTB and then enable the latch by sending a logic 1 to PORTA pin 1, then make it a zero again. lastly - send out your anode data to PORTB and then send a logic 1 to PORTA pin 2 to enable the anode latch, then make it a logic 0 again.
Now we have three chips, each with their required data. We then make PORTA pin 3 (the output enable connection) a logic 0 (we need it to be a 0 because it has an inverted input at the 74373 for this connection)
This will allow all the data present in the 74373 chips to go out and be displayed on the LED matrix.
Have a look at the 8x8 game system page for full details and a schematic of how I made it all work.
Thanks a lot, I think I have understood the theory. I'm gonna do some reading about the subject

I'm about to buy some Motorola MC74F374N, they seem to do the same as 373.
Sorry for a late reply to an old post...
I'm not sure the Motorola MC74F374N is a good choice as the output current specs' seem a bit low, however, there may be advantages using a 74HC374 over a 74HC373. Both parts have the same output current specs and the same pinout but the '374 is an edge triggered D flip-flop. This means that while you can use the '374 in a circuit the same way Brad uses the '373 in his 8x8 Game System, you can also cascade multiple '374 ICs by driving all the CLK and /OE pins together and by connecting the outputs of leading ICs to the inputs of following ICs. The modified 8x8 Game System schematic below shows three 74HC374 ICs in cascade configuration. Now the neat part about this configuration,
besides freeing up four I/O pins, is that writing 24 bits of output data to the '374 cascade simply involves clocking three bytes onto the bus. As each byte is written onto the bus it ripples down the cascade. In this case, you must send the Green byte first, followed by the Column byte, followed by the Red byte. I believe the process is simpler and faster than the one described by Brad for the '373 and should result in smaller more efficient code. For example, the code snippets below from the "Invaders" program, which have been modified for the 74HC374 cascade, are nearly 40% smaller than the original code they replace.
Food for thought. Cheerful regards, Mike
Code:
;******************************************************************
; 8x8 Game System "Invaders" draw routines for 374/574 hardware *
;******************************************************************
ship
btfsc stop_repeat,1 ; |B0
call button_time ; |B0
call joystick ; check joystick |B0
movlw 0 ; |B0
call latch ; GRN = 0 (off) |B0
movf ship_data,W ; |B0
call latch ; COL = ship_data |B0
movlw b'00000001' ; |B0
call latch ; RED = 00000001 (bottom row) |B0
goto display ; |B0
;******************************************************************
;
draw_UFO
btfss do_UFO,0 ; ??? |B0
return ; |B0
movlw 0 ; |B0
call latch ; GRN = 0 (off) |B0
movf UFO,W ; |B0
call latch ; COL = UFO |B0
movlw b'10000000' ; |B0
call latch ; RED = 10000000 (top row) |B0
call display ; |B0
decfsz UFO_speed,F ; move ufo? yes, skip, else |B0
return ; branch (done) |B0
movlw d'30' ; |B0
movwf UFO_speed ; reset 'ufo move' timer |B0
rrf UFO,W ; rotate UFO left |B0
rrf UFO,F ; pseudo 'rrncf' (uses carry) |B0
skpnc ; full cycle? no, skip, else |B0
bcf do_UFO,0 ; flag a full UFO cycle |B0
return ; branch (done) |B0
;******************************************************************
;
shields
movlw b'00000010' ; |B0
call latch ; GRN = 00000010 (shields row) |B0
movf shield,W ; |B0
call latch ; COL = shield |B0
movlw 0 ; |B0
call latch ; RED = 0 (off) |B0
goto display ; |B0
;******************************************************************
; draw alien rows: top = red, middle = green, bottom = yellow
;
draw_aliens
movlw 0 ; |B0
call latch ; GRN = 0 (off) |B0
movf top_alien_dat,W ; |B0
call latch ; COL = top_alien_dat |B0
movf top_alien_row,W ; |B0
call latch ; RED = top_alien_row |B0
call display ; |B0
movf mid_alien_row,W ; |B0
call latch ; GRN = mid_alien_row |B0
movf mid_alien_dat,W ; |B0
call latch ; COL = mid_alien_dat |B0
movlw 0 ; |B0
call latch ; RED = 0 (off) |B0
call display ; |B0
movf bot_alien_row,W ; |B0
call latch ; GRN = bot_alien_row |B0
movf bot_alien_dat,W ; |B0
call latch ; COL = bot_alien_dat |B0
movf bot_alien_row,W ; |B0
call latch ; RED = bot_alien_row |B0
goto display ; |B0
Code:
;******************************************************************
; 8x8 Game System 74HC374/574 Hardware Support Subroutines *
;******************************************************************
latch
movwf PORTB ; place WREG data onto data bus |B0
bsf PORTA,0 ; CLK = 1 (latch cascaded data) |B0
bcf PORTA,0 ; CLK = 0 " |B0
return ; |B0
display
bcf PORTA,1 ; /OE = 0 (display on) |B0
call delay ; display 'on' time |B0
bsf PORTA,1 ; /OE = 1 (display off) |B0
return ; |B0