==================================================================== DR 6502 AER 201S Engineering Design 6502 Execution Simulator ==================================================================== Supplementary Notes By: M.J.Malone Trouble Shooting the 6502 Project Board ======================================= Quick Checks ============ There is only one important thing to keep in mind when faced with a non-functioning 6502 board. The board is just a series of traces. The errors in the trace pattern are well known and once fixed using the jumpers described in the project board notes, their is no reason for a board not to work except for reasons of software, power, bad chips and wiring mistakes. The quick diagnosis methods and quick are given below. A Software Error ---------------- Many times when a design group is trying something the test fails, the software person is blamed. After a recheck of the program source code, the programmer says confidently, "Just look at this code, it is so simple how could there be an error? It must be 'the board' !". After several hours the software person discovers that they have typed: lda DDRA_Port_Mask ; The mask for the I/O pattern of Port A sta DDRA instead of: lda #DDRA_Port_Mask ; The mask for the I/O pattern of Port A sta DDRA If the bit pattern 'DDRA_Port_Mask' were interpreted as an address as in the first example, of course nothing works. There are many such one character errors that are very difficult to see late at night on the fourth check of the source code especially when the checker is convinced there is no error. The solution is to have a test EPROM around at all times that checks all components of the computer. Whenever a dispute of 'Is the error in hardware or software?' arises simply plug in the test EPROM and see if the board performs as expected or not. An example test EPROM program is given in BOARDTST.ASM. If your board has failed such a test as the one given in BOARDTST.ASM then continue. page 2 Bad/No Power ------------ Check the power supply, batteries and connections. Check WITH A VOLTMETER the actual voltage being produced by the 7805 power regulator. The +5 volt trace is the one connected to the regulator pin next to the edge of the board. This trace runs the length of the board and has connections to several 10K resistors and at least one capacitor. The ground trace is connected to the middle pin on the power regulator. If the voltage is greater than 5 volts (like maybe 7-12 volts) see: 'Over Voltage' below. If the voltage is less than 5 volts (like maybe 0-4 volts) see 'Under Voltage' below. If the voltage is 5 +/- .1 volts then proceed. Bad Chip -------- It is possible that you have a bad chip. First check that your check EPROM is good by checking it on someone else's computer board. If the EPROM is OK then put it back in the non-functioning board and proceed to swap chips with the working board ONE AT A TIME. If at some time the working board stops working or the non-functioning board checks out you can determine which of and how many bad chips you have. Wiring Mistakes --------------- Probably the fastest way to check if there is a wiring mistake is to have someone else look at your computer board, preferably comparing it to a functioning board. Check the EPROM jumper is correct and in place and measures 5 volts. Check that there are two jumpers near the 74xx04. Check that one has a polarity of +5volts and the other GND. Check that there is a jumper near the 74xx74. Check that this jumper has a voltage of GND. Check that there is a jumper on the bottom of the 6502 and that it measures 5 volts. Check the polarity of the tantalum capacitors. Trouble Shooting Procedure ========================== Though all non-functioning computers will fail to function from one of the above causes, a more detailed trouble-shooting procedure will be developed. After this several symptom-solution scenarios will be presented. 1) Connect the computer board to +12 and GND connections on the power supply. Place you finger on the back of the 7805 power regulator and turn on the power supply. If the regulator becomes uncomfortable to touch then go to 'High Current Drain'. If the regulator does not become hot then continue. page 3 2) First we will check the output of the 2 MHz clock circuit. Check pin #6 on the 74xx04 chip with an oscilloscope set to 1 microsecond per division and 1 volt per division with the GND level at the bottom of the screen. If the pin shows an AC signal that is a rounded square wave of 2 MHz frequency (two complete cycles per division) then advance to step 5. If the signal is at either 0 volts or 5 volts (almost exactly) then go to step 3. If the signal is between .7 volts and 2.7 volts then go to 4). 3) You are at this step because the clock oscillator which is supposed to be astable has latched into the high or low state. This is simply not possible if everything is connected and the 74xx04 is even close to working. Check the connection of the crystal, two resistors and the .1 microF capacitor. Try also replacing the 74xx04 chip. 4) You are at this step because your clock signal is not starting by itself but instead is sitting in an equilibrium state. We will try disturbing its equilibrium a bit. Touch the leads of the crystal with your finger while continuing to probe the 74xx04 chip. If an AC signal develops then the solution to this problem is to turn off the power, connect a 100-1000pF capacitor from the square GND area to one of the leads of the crystal and then power up. If the AC signal develops immediately then continue to step 5 otherwise increase the capacitance and try again. 5) You now have a functioning 2 MHz clock unit. Probe pin #37 of the 6502. The signal should be a square wave of frequency 1 MHz, one cycle per division. If this is the case advance to step 8). If the signal is a square wave but at a frequency of 2 MHz then go to step 7) otherwise continue to step 6). 6) You are here because your 74xx74 chip is probably not functioning. Check it by swapping the chip and also check the jumper near the 74xx74 chip that it is 0 volts. Try removing the 6502 chip and see if the problem persists. If the clock signal becomes normal then perhaps the 6502 is blown or the 74xx74 is blown. 7) You are here because you have the 2 MHz clock problem as described in the assembly notes. Try the solution as described in the printed notes you received with your computer board. 8) You have a proven CPU clock. Next test to see if the 6502 properly resets. Check the voltage on pin #40 of the 6502 using an oscilloscope. The voltage should be 5 volts. It is normal to see small spikes in the 5 volt level of approximately +/-.3 volts. Press the reset button and check that the voltage is 0 volts. If the voltage is the opposite to that expected then it is probably that you have a momentary open switch not a momentary closed switch as specified. If this is the case then you can still test your computer temporarily by holding the reset switch but you should replace the switch at the earliest opportunity. page 4 9) You now have a proven Reset circuit. Next test to see if the 6502 is executing instructions by probing the SYNC signal of the CPU. The SYNC signal goes high every time the CPU fetches an opcode of program. The SYNC signal can be monitored by probing pin #7 of the 6502. Note: to get the pulse pattern to be stationary on the screen and not covered with ghosts and flickers, set the time base on 10 microseconds per division and then adjust the time base 'cal' knob slightly until the pattern locks in with the fewest ghosts. Set the times 10 sweep magnification on the time base. The time base should be effectively just a bit more than 1 microsecond per division. By adjusting the horizontal position knob, you will be able to scan through the series of pulses. The opcode fetch will last 1 microsecond. This pulse will be followed by at least 1 microsecond low. NOP, LDA #, TAY, BNE (not taken), SEC are all instructions that will take two machine cycles (microseconds) and will be seen on the oscilloscope as one cycle high followed by one cycle low. The longest instructions (cycles) are RTS (6), BRK (8) and Reset (6). On average, most instructions will show 3 or 4 cycles since all non-indexed memory fetches, jumps and arithmetic or logical statements are 3 or 4 cycles. It may seem for very long programs that it would be impossible to use this sort of count the cycles type analysis but it is usually not. Since most programs have one small segment of the code that is executed most of the time (like the innermost nest of a delay loop) it is possible to assume that most of what you see on the screen that small part of the program with the ghosts being the other parts of the program. By this method it is possible to determine whether the 6502 is executing the program intended or not. Summary ------- If the above procedure does not lead to a cause of the problem then the recommended procedure is to trim down the program to its minimum, and attempt chip swapping again paying particular attention to the VIA's, CPU, EPROM and RAM. It may also be possible that a poor soldering job may have left some connection not connected. If this is suspected then it is recommended that the board be inspected by someone, preferably someone else, and suspicious areas be touched up. Your computer board will work eventually. If there are no missing jumpers and no bad chips the test EPROM must check out. Symptoms/Cures ============== Symptom: Over Voltage --------------------- First there are three possible causes for this. The power regulator is designed to produce at least 5 volts. If there is another source of voltage on the board of greater than 5 volts, the page 5 system voltage may rise above 5 volts. This is commonly caused by some user circuit or input to a CMOS VIA. The obvious remedy is to turn off all external voltage sources and recheck the system voltage. The second problem may be simply that the +12 volt power supply has been mistakenly connected to the +5 volt connection on the bottom of the circuit board. The third possible problem may be that the 7805 is blown and not operating properly. The over voltage condition is very serious and can lead to destruction of ALL of the chips in the system (the $35 mistake). Symptom: Under Voltage ---------------------- If the voltage in the system is low and the 7805 power regulator is not getting uncomfortably warm then this can only mean that the 7805 is defective or is not properly connected or the measurement of voltage is not being done properly. If the 7805 is getting uncomfortably hot to touch then go on to 'High Current Drain'. Symptom: High Current Drain --------------------------- This assumes that the VIA's are not connected to any circuitry which may be causing large currents to be drawn from the board. If the VIA's are connected to external circuitry then disconnect them and begin again. If NMOS 6502 or 6522 chips have been used then it is quite possible that there is nothing wrong at all. An computer with an NMOS 6502 and two NMOS 6522s can easily draw 1 ampere as compared to 0.024 milliamperes (yes a factor of 40!) for an all CMOS computer. This extra current draw is enough to make any 7805 a bit hot. For testing, it is possible to bypass the regulator and feed the computer board from a high current supply for testing purposes but it is recommended that the NMOS components be replaced with CMOS at the earliest possible opportunity. It is entirely possible that the board may not work at all with too many NMOS components because of voltage drops over the lengths of the fine traces used to make the circuit. This can be caused by a bad chip, a short circuit in the wiring or a bad tantalum capacitor. To check to see if a bad chip is to blame, try removing the chips one by one and trying again each time. If the current drain disappears then the last chip removed may be the cause. Another troubleshooting method recommended is to bypass the 7805 and connect a high current 5 volt supply directly to the 5 volt rail of the board. Turn on the power and quickly check all chips with the back of a finger (because it is most sensitive to heat) to look for one that may be heating. NMOS and TTL chips may become warm but will never be hot under normal operation. Transistors and regulators may become hot but will never be uncomfortable to touch. If none of the chips seem to be heating then leave the power on and check the voltage and current being page 6 output by the supply. If the supply voltage is very close to zero then there is likely a short in the wiring (see next heading). Wait a short time and look for smoke (big white clouds of smoke) from one of the tantalum capacitors. If one of the capacitors is bad it will progress from smoke to flames quickly so stand by the off switch. As soon as heat is detected from a chip or smoke from a capacitor shut off the supply and replace the component. See if there is still a problem with a high current drain. Symptom: Unlocatable Short Circuit ---------------------------------- Sometimes there is an unlocatable short circuit somewhere on the board, usually the result of a poor soldering job or a resistor or capacitor lead bent over and touching another area. If the board has been thoroughly inspected by several people and the error is not obvious then there is another suggested course of action. Remove all the chips from the board and bypass the regulator with a high current variable supply. Adjust the current limiting or the voltage until the current flowing through the board is something between .05 and .1 amperes. Using a voltmeter set to read millivolts, measure the voltage across the power supply. If the voltage is too great to be read in millivolts do not become alarmed, this is actually better. The idea here is than any trace that has a current flowing through it also has a small voltage drop along its length. If you start where you have connected the -ve lead of the power supply and test all paths leading from it there will be one with a significant voltage difference in millivolts along some test length. This path is the one that leads to the short circuit. Continue to leap frog along until you find your way back to the +ve lead of the power supply. Somewhere on the path you will discover a wrong connection and there is your short.