From: Rick_Michael_Cortese@cup.portal.com
Newsgroups: comp.sys.atari.8bit
Subject: Adding a 2nd PIA
Date: Fri, 11 Sep 92 15:30:01 PDT
Organization: The Portal System (TM)
  <65609@cup.portal.com>

Well, I finished what had to be the quickest/easiest hardware
project I've ever done. This isn't the best way to implement
additional functions to an 8-bit, but I mainly did it to make sure
the (M)emory (M)anagement (U)nit sends out the proper signals for
the mod I have in mind.  Since it adds and additional 6520 with
it's 16 I/O lines & interrupt capability it may be enough for
someone who just wants to do [robotics, home control, memory
expansion, ...].  A bit of background on the Atari Memory Map.
The way Atari implemented the hardware was to decode the address &
use that to select the chips to be loaded or read on the data bus.
It's the MMU that takes care of things like switching basic on or
off, reading the joystick ports etc.  For any memory access in the
$D000 to $D7FF area, the MMU puts an enable pulse to a 74LS138.
The 74LS138 is an decoder that selects one of 8 possible outputs
depending on what is on it's address pins. In the Atari case, they
tied address lines A8, A9, & A10 to the address pins so when the
smallest unit of measure is 256 bytes with respect to the address
bus. Eight possibilities from 3 address lines =>2K of hardware.
This is the hole you always hear about when people ask why we
can't access the entire 16K of ram under the OS. Why didn't they
just use address lines A5, A6, & A7?  I don't know, but it
would've saved 1.8K of space.  As it turns out, they probably did
us a favor since it makes adding additional chips trivial.  Like I
said, the 74LS138 is a one of 8 decoder, but have you ever counted
the LSI chips in your computer? Antic & the CPU take care of
themselves, so the only lines that are used on the 74LS138 are O/0
for GTIA @ $D000, O/1 @ $D100 for the enhanced cartridge interface
on the XE, O/2 @ $D200 for Pokey, O/3 @ $D300 for the PIA, & O/5
for the cartridge control line. Antic decodes it's own stuff @
$D400 thank you!  Outputs on pins [4, 6, 7] aren't used anywhere
on anything.  Since this is a minimal project, I just used the O/7
(pin #7 of the 74LS138) for the project.  This mod was done on an
800XL, but should work for a 1200XL or XE.  Buy any one of the
following; 6520, 6521, 6821. I left the input pins CA1 & CB1 tied
to the existing 6520, this should prevent spurious interrupts. As
far as I know, PIA interrupts are not used by anything, but if
someone every uses them, the software may have some trouble
clearing the 2nd 6520's status.  Bend out the following pins: [2-
17, 19, 23, 39].  Piggy back/solder the remaining pins to the
existing 6520. Run a wire from pin #7 of the 74LS138 to pin #23 of
the new 6520.  That's it! Pins 2-17 are the PORTA & PORTB I/O pins
respectively. What I did to check out the circuit is wired a
single 220 Ohm resistor to the +5V supply on pin #20 of the 6520,
then ran LEDs from it to each of the bent-out pins of PORTA.  To
run it through it's paces just:

 10 PORTA=55040:PACTL=55042
 20 POKE PACTL,0
 30 POKE PORTA,255
 40 POKE PACTL,4
 50 FOR N=0 TO 255
 60 FOR DELAY =1 TO 300:NEXT DELAY
 70 POKE PORTA,N
 80 NEXT N
 90 GOTO 50
)
4              REQUEST TO SEND (RTS)
20             DATA TERMINAL READY (DTR)
23