(Inspired by Garth's text for the 6502, and because I have to figure it for the Übersquirrel, I've but together this list. I'd be grateful for corrections (which I'm sure are necessary) and comments, etc. Then at some point, we can hopefully get rid of the next line.) *** THIS TEXT IS UNDER REVIEW AND SHOULD NOT BE TRUSTED ***(Last change 7th Sep 2015: Replaced link to VDA backgrounder)
This is a list of all the pins on the 65816 processor, what they do, and what you can do with them. It is inspired by Garth Wilson's
What Do I Do With the "Mystery" Pins, SYNC, RDY, S.O., Φ1, MLB, BE, and VPB? for the 6502 (
http://wilsonminesco.com/6502primer/MysteryPins.html). Since there is some overlap, it is recommended that you read that text first -- some things are covered in more detail there and not repeated here. The information is taken from the WDC Data Sheets and various forum discussions, see the link list at the bottom of this text.
Code:
/=============\ /=============\
VP I1 40I RES Vss I1 40I RES
RDY I2 39I VDA RDY I2 39I o2 (OUT)
ABORT I3 38I M/X o1 (OUT) I3 38I SO
IRQ I4 37I o2 (IN) IRQ I4 37I o2 (IN)
ML I5 36I BE NC I5 36I NC
NMI I6 35I E NMI I6 35I NC
VPA I7 34I R/W SYNC I7 34I R/W
VDD I8 33I D0/BA0 Vdd I8 33I D0
A0 I9 W65C816 32I D1/BA1 A0 I9 6502 32I D1
A1 I10 31I D2/BA2 A1 I10 31I D2
A2 I11 30I D3/BA3 A2 I11 30I D3
A3 I12 29I D4/BA4 A3 I12 29I D4
A4 I13 28I D5/BA5 A4 I13 28I D5
A5 I14 27I D6/BA6 A5 I14 27I D6
A6 I15 26I D7/BA7 A6 I15 26I D7
A7 I16 25I A15 A7 I16 25I A15
A8 I17 24I A14 A8 I17 24I A14
A9 I18 23I A13 A9 I18 23I A13
A10 I19 22I A12 A10 I19 22I A12
A11 I20 21I Vss A11 I20 21I Vss
\=============/ \=============/
(Image source:
viewtopic.php?f=4&t=2883)
The pins are referenced by number, not by name, so you can systematically go through each one when installing a 65816. A "B" at the end of the pin's name means that it is asserted by going low, that is, the default state is high. At the end of each description, there is recommendation for simple, slow systems -- the "when in doubt" usage. Follow these recommendations at your own risk.
PIN LIST
01 VPB "Vector Pull" (Output). Is asserted (goes low) whenever any of the hardware vector addresses are being accessed during an interrupt request, the same behavior as with the 65c02 (where things get tricky depending on the manufacturer, see Wilson). You could use this signal to select and prioritize interrupts from several sources. VPB is also asserted during the execution of BRK and COP; it goes low during cycles 7 and 8 of the interrupt acknowledgement sequence. Note that if you are replacing a 6502 from a company that is not WDC with a 65816, you might have to use trickery because this is GND for other versions. -- In a simple system, leave this pin unconnected.
02 RDY "Ready" (Bidirectional). As an output, it is pulled low by the processor after WAI is executed, signaling that the 65816 is WAiting for an Interrupt. It is then pulled high again when an external RES, ABORT, NMI or IRQ interrupt is active. As an input, a low level will halt the processor, which can be used for things like single stepping, slow memory access, or DMA. After the return to the active high state, the processor will continue running after the next PHI2 negative transition. The processor will not stop after a WAI instruction if RDY has been forced to a high state. The STP instruction has no effect on RDY. If RDY is to be driven by another chip, use a Schottky diode, with the anode connected to RDY. -- If you are not going to use it, pull it up with a 3.3k resistor. Do not apply to VDD (+5 V) directly: If RDY is tied to VDD and WAI is executed, the 65816 will attempt to sink VDD, which is bad.
03 ABORTB "Abort" (Input). When asserted by a negative level, the current instruction is aborted (actually, it is completed, but the results are not saved, so it isn't really an abort), a bunch of interrupt stuff is done, and then control is transferred to the address saved in the Abort Vector at 00:FFF8 (emulation mode) or 00:FFE8 (native mode). For more detail, see BDD's Investigating 65c816 Interrupts (
http://sbc.bcstechnology.net/65c816inte ... rupt_abort). This pin could be used for handling page faults in complicated memory systems, but that's rare, and the timing requirements are tricky. -- Normal people pull it up with a 3.3k resistor or tie it to VDD.
04 IRQB "Interrupt Request" (Input). If the disable interrupt flag of the processor is clear (CLI instruction), a negative level on this pin will start the interrupt sequence. In emulation mode, three bytes are pushed to the Stack -- the two bytes of the Program Counter (PC), high byte first, and the Status Register (P) -- and control passes to the interrupt vector at 00:FFFE-FFFF. In native mode, four bytes are pushed to the stack: the Program Bank Register (PBR) and then PC and P as with emulation mode. Control then passes to the vector at 00:FFEE-FFEF. When these vectors are accessed, the VPB pin goes low (see above). You can use the WAI (WAit for Interrupt) instruction to make sure the interrupt will be recognized immediately. For more detail, see BDD's Investigating 65c816 Interrupts (
http://sbc.bcstechnology.net/65c816interrupts.html . -- Connect this pin to your interrupt lines.
05 ML "Memory Lock" (Output). Is asserted low during the execution of the read-modify-write (ASL, DEC, INC, LSR, ROL, ROR, TRB, TBS) instructions, which tells other players on the bus that it can't be used right now. Potentially useful for multiprocessor systems. -- Leave unconnected.
06 NMI "Non-Maskable Interrupt" (Input). A high-to-low transtion -- not a low level -- starts an interrupt sequence that cannot be blocked after the current instruction is completed. The current address and the Status Register are pushed on the stack just as with the IRQB sequence. However, the vectors are different: In emulation mode, control is passed to 00:FFFA-FFFB and in native mode to 00:FFEA-FFEB. Here, too, you can use the WAI (WAit for Interrupt) instruction to ensure immediate service. For more detail, see BDD's Investigating 65c816 Interrupts (
http://sbc.bcstechnology.net/65c816interrupts.html . -- If you don't use this interrupt, tie it high by connecting it to VDD.
07 VPA "Valid Program Address" (Output). Together with the Valid Data Address (VDA) line (pin 39, see below) they tell the other hardware that the address is okay. This can be used to handle DMA schemes or caches. VPA is asserted during both the opcode and operand fetch steps. A table is used to explain them:
Code:
VDA VPA
0 0 - Internal Operation
0 1 - Valid program address
1 0 - Valid data address
1 1 - Opcode fetch
The important part: when both are are zero, the address bus is in an undefined state and may change states more than once before becoming valid. This can cause non-65xx devices to misbehave. When both of them are asserted (high, "opcode fetch"), this is the equivalent to the 6502's SYNC line. Put simply, when either are high, the address bus is valid. This can be handled with an OR (or NOR) gate. BDD has a detailed discussion of what to do with these lines at
http://sbc.bcstechnology.net/page007.html , and Dr. Jefyll offers a second description at
viewtopic.php?f=4&t=3404&start=15#p40104. -- A careful design will qualify the address with a logical VDA OR VPA.
08 VDD "Supply Voltage" (Input). Where the power comes from. Connect to 5V directly.
09-20, 22-25: Address pins A0-A15 (Outputs). Same job with the 6502. The Address Buffer can be switched off ("set to the high impedance state") externally by the BE pin. -- Connect to address bus.
21: VSS "Ground" (Output). Connect to ground.
26-33: Data pins D0-D7/Address pins BA0-BA7 (Bidirectional). The 65816 can access 16 MByte of data, which requires 24 address pins. However, only 16 (9-20, 22-25; see above) are dedicated to the address. The other eight share double-duty with the data bus. Roughly: With the 6502, when PHI2 (Clock, pin 37) is high, the data is driven on the data bus (fans of Star Trek Next Generation will remember that "Data always takes the high road"). When PHI2 is low, neither the processor nor the system drives the data bus. This means there is "dead time" between individual reads and writes that is nominally half of the cycle. The bus is relinquished to the system. With the 65816, there is no more dead time: When PHI2 is high, the processor drives the data bus as usual. During PHI2 low, the processor drives the Bank Address to on these pins. This happens even in emulation mode, though only zeros are fed to the system.
(Note the address and data buffers can be switched off externally by asserting BE ("Bus Enable", pin 36) so that other devices can use the busses. See below for further discussion.)
There is a standard circuit in the 65816 data sheet for dealing with this situation:
Attachment:
65816 Bank Address Latching.gif [ 15.86 KiB | Viewed 11152 times ]
For the data bus, use a buffer such as the 74ABT541, gated to high-Z-state when PHI2 is low. For the bank address, use a latch such as the 74ABT573 or 74ABT245 when PHI2 is high. If you only access the "original" 64 KByte bank, you don't need the latch. Note that this all becomes slightly more complicated because of the VDA/VPA pins. See the discussion about qualifying this circuit with those signals in this thread.
34 RWB, R/W "Read/Write" (Output). When high, the processor is reading data from memory or interface devices. When low, it is writing to them. This pin remains high during reset and is affected by the BE pin, see below. RWB should be qualified by O2 in systems using non-65xx devices, as D0-D7 are never valid data during O2 low. Many non-65xx devices have separate /RD and /WD inputs that require some additional logic on RWB. -- Connect to R/W on chips and glue logic, but note the discussion on VDA/VPA and the data pins.
35 E "Emulation Pin" (Output). Reflects the state of the processor's emulation bit (E). In other words, it tells you if the system is in emulation or native mode. Can be used, for instance, change the system memory map between emulation and native modes, or to power an LED showing the processor's state (if it remains in that state long enough). -- Leave unconnected.
36 BE "Bus Enable" (Input). When BE is low, the Address and Data buffers are disabled, as is R/W, letting other parts of the system access the busses. This is an asynchronous signal. Rarely used. -- Attach to VDD through a 3.3k resistor.
37 O2 "Clock", "Phase 2" (Input). The clock input for the processor. The 65816 is a bit fussy about the quality of the signal, so when in doubt, run it through a 74ABT74 flipflop to sharpen the waveform. -- Attach clock signal to this pin.
38 M/X "Memory and Index lines" (Output). Tells you if the the Accumulator (M) and Index Flags (X) are set -- like E, this gives you information about which mode the processor is in. Most people don't care, and it's hard to think some real-world use for this pin anyway. -- Leave unconnected.
39 VDA "Valid Data Address" (Output). See discussion pin 7, VPA.
40 RESB "Reset" (Input). Asserted (pulled low) for at least two clock cycles sets the 65816 back in emulation mode and starts the reset sequence. -- See
http://wilsonminesco.com/6502primer/RSTreqs.html for a discussion of the circuit required.
LIST OF ADDITIONAL CHIPSWhat this all means is that in contrast to a 6502, the 65816 will need some additional glue logic. Definitely required:
74ABT245 - Octal transceiver with direction pin, 20 pin DIP, as a latch for the Bank Address Bus
74ABT541 - Three-state octal bus, 20 pin DIP, as a buffer for the Data Bus
74ABT04 - Inverter, 14 pin, for connecting PHI2 to latch for Bank Address Bus
Recommended for some situations, but not necessarily showstoppers:
74ABT74 - D-type Flip-Flop, 14 pin DIP, to sharpen PHI2 waveform
74ABT32 - OR-gate, 14 pin DIP, for address qualification with VDA and VPA.
The ABT family is chosen for its speed.
LINKSComparing the 6502 pinout to that of the 65816:
viewtopic.php?f=4&t=2883 Managing the 65816 Multiplexed Bus:
viewtopic.php?f=4&t=2438Replacing 6502 with 65816 in a Commodore:
http://www.baltissen.org/newhtm/02to816.htmDUART VPA/VDA problems:
http://sbc.bcstechnology.net/page007.htmlMystery Pins of the 6502:
http://wilsonminesco.com/6502primer/MysteryPins.htmlWikipedia: Interrupts in 65xx Processors:
https://en.wikipedia.org/wiki/Interrupt ... processors