6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Tue Jun 04, 2024 4:19 am

All times are UTC




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Weird 6502 problems
PostPosted: Tue Jun 23, 2020 8:15 pm 
Offline

Joined: Tue Jun 23, 2020 7:34 pm
Posts: 5
Hello,

I have recently been making a simple 6502 computer (RAM, ROM, VIA, ACIA) and have successfully got it up and running. I was building it on solderless breadboards for easier prototyping. In order to make it a bit more permanent and because of the bugginess of cheap breadboards, I decided to migrate to a soldered version on perfboard. As was to be expected, after soldering everything together, it didnt work...

After doublechecking everything etc., I still didn't get it to work. I did find one error though: I drove the reset signals as active high, meaning that they were by default low... It was also around then that I discovered that my 6502 was heating up considerably (not burning hot, I guess 40-50C). I don't recall the chip to be running that hot before, but I also don't recall it NOT to run that hot. It is an old 6502 from Aliexpress, marked on top as MOS 6502, but on the bottom as a Rockwell one (so probably a salvaged Rockwell 6502 that got re-branded). Might this be related to http://forum.6502.org/viewtopic.php?f=4&t=1927? It does however also heat up when reset is high but maybe that is because while debugging, reset has probably been low for a minute, causing permanent damage.

Still no success, so I decided to try to get things working again on the breadboard, to make sure I hadn't completely forgotten something, because I haven't drawn any schematics. Hardwiring NOP works, because the program counter increments. I then programmed an EEPROM with some NOP's, and connected that to the 6502. Running the 6502 at 1Hz, I confirmed that it was indeed reading the NOP's, and that each instruction took about two cycles. But then running it at a higher frequency, I mostly just measured garbage on the data lines and address lines. They just were always low or always high. Another curious phenomenon I had also been seeing, was that sometimes after reset, I just measured high frequency oscillations between 0 and 5v on all the data lines and address lines. I don't know the exact shape or frequency, because my cheap-ass 200khz scope can't measure that.

I then decided that the best way to confirm whether the breadboard system was actually working or not, was to also connect a 6522 VIA, and make a program that just toggles pins. At first it didn't work, but just today I decided to run it at 100khz instead of the 1mhz I was normally running at, and behold; it worked. Sadly, rather unstable: after a random period of 10-30 seconds, it just stops. Strangely enough, that period is inversely proportional to the clock frequency. Running it at 1mhz, I only sometimes get a brief flash of pulses. But it does confirm that the 6502 at least isn't completely broken.


Now I don't have any idea what to do anymore, so my questions to you are: Are my measurements normal, or at least, explainable? Could it just be that I somehow damaged my chips? Do you know of any further debug steps to be taken? Or just general advice?

Frank


Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Tue Jun 23, 2020 8:25 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10821
Location: England
Welcome!

I think I might summarise your experience as showing that making a working computer isn't as simple as it might seem at first: you built it, and it worked, then you rebuilt it, and it didn't. That's a reasonable lesson, I think, and no harm done.

The thing to do is to proceed with care, and take notes. You should certainly know what your design is, so that most likely means an accurate schematic, either before or after your build. You'll see many threads this year here on the forums from people doing first-time construction, and you'll see many ways in which things can come unstuck: design errors, misconceptions, wiring errors, and so on. Any of these are easy mistakes to make: the solution is to take care, re-inspect and measure what you've done, and when it comes to debugging, proceed methodically.

If you have the persistence, you can surely get a working implementation of a good design. But it will take a certain amount of work.

You'll find lots of help here on these forums, and that will go much more smoothly if you're careful in describing what you've done, what you see, what you changed. My recollection is that people who jump ahead several steps and don't quite know what they've done are more likely to get frustrated and give up.


Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Tue Jun 23, 2020 9:03 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3363
Location: Ontario, Canada
BigEd wrote:
You'll find lots of help here on these forums, and that will go much more smoothly if you're careful in describing what you've done
Yes -- and including schematics and photos can be helpful. (On this forum you're allowed to attach images with your post.)

fvp wrote:
Running the 6502 at 1Hz, I confirmed that it was indeed reading the NOP's, and that each instruction took about two cycles. But then running it at a higher frequency, I mostly just measured garbage on the data lines and address lines.
This maybe doesn't mean much, as lot of the NMOS chips were only rated for 1 MHz anyway.

As for the mysterious topic of reset heating, maybe we can simply sidestep it and move forward. Possibly there's been some heat damage but I doubt it. In any case the goal now is to see if the chip can be made to work.
.

Cheers (and welcome, by the way!)
Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Wed Jun 24, 2020 6:32 am 
Offline

Joined: Tue Jun 23, 2020 7:34 pm
Posts: 5
Thanks for your replies. I attached schematics for the breadboard computer.

I personally think that I did somehow damage the 6502, why would it otherwise get warm? Or is that normal?

Quote:
In any case the goal now is to see if the chip can be made to work.

As I said, I have confirmed it does still work, but unreliably.


Attachments:
6502BreadboardSchematic.png
6502BreadboardSchematic.png [ 1.64 MiB | Viewed 1421 times ]
Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Wed Jun 24, 2020 1:11 pm 
Offline

Joined: Tue Jun 23, 2020 7:34 pm
Posts: 5
Further developments:

I decided to investigate the unreliableness a bit more. I tried adding a schmitt trigger using a comparator after the signal generator to make sure I was giving a clean signal to the NOT buffer. That didn't seem to have any considerable effect. After that, I decided to measure what was on the data and address lines after the 6502 randomly stops, and I saw that it was reading $00 at address $FFFF. That is of course the location for the irq/brk vector, so I though it was maybe for some reason stumbling upon a brk, and therefore trying to go to location $0000. I don't know what would then cause it to simply stop, but it apparently did. To confirm this hypothesis, I programmed the eeprom to let $FFFE/$FFFF point to the address of my loop. That worked, and it ran a lot more stable: up to 800khz it didn't stop anymore, but going any higher than that would still cause it to stop after a while.
Still suspicious about the quality of the clock signal, I tried removing the schmitt trigger to see if it would have any effect, and it did; it was way less reliable without. This confirmed that the clock was probably the source of my problems. I also tried hooking up a 555 to act as a clock source. That didn't work, however, I discovered that I had been using 680R resistors instead of 6K8... After changing that, and after changing the hysteresis ratio a bit, the 555 also worked, but it still wasn't reliable. But, after I changed back to the signal generator, it díd work! Even after removing that brk vector, it was still reliable up to 1mhz.
My conclusion: I probably had a very noise signal generator output, which sometimes caused unwanted extra clock cycles or something, messing up the 6502. That caused it to sometimes read $00 as an opcode instead of as part of an address, and therefore jumping to the address at $FFFF, stopping the cpu. Using the schmitt trigger, the noise was removed and that solved it.

This also means that my 6502 indeed isn't broken, and that my soldered prototype probably has some other problem somewhere, so that is what I'll try to find now.

This is my test program, by the way:
Code:
VIA = $0000

VIA_DDRB = VIA + 2
VIA_PORTB = VIA + 0

.org $FFFC
.word init

/*
This is what I added:

.org $FFFE
.word loop
*/

.org $F000
init:

   lda #$FF
   sta VIA_DDRB

loop: //(I removed the extra nop's)

   lda #$FF
   sta VIA_PORTB

   nop

   lda #$0
   sta VIA_PORTB

   nop

   jmp loop


Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Wed Jun 24, 2020 1:24 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10821
Location: England
Good investigation and result! It might be worth noting that problems in power supply decoupling, or noise on the ground line, can also work the same way as noise on the clock. So, clock and power are well worth getting very clean.


Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Wed Jun 24, 2020 2:00 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3363
Location: Ontario, Canada
BigEd wrote:
It might be worth noting that problems in power supply decoupling, or noise on the ground line, can also work the same way as noise on the clock. So, clock and power are well worth getting very clean.
Yes, this is certainly important. It's not a good sign that you were "measur[ing] high frequency oscillations between 0 and 5v on all the data lines and address lines." :shock:

Prior to your latest post I began some annotations to your schematic, which I will share now. On older 65xx systems it was SOP to take the Phi2 and /Phi2 signals from the outputs on pin 39 and pin 3 of the 6502, and as you're using vintage parts it may be helpful for you to do the same, rather than taking them from the input side (where I've marked). It may also be helpful to feed /Phi2 to the /OE input of the 28C256, for the reasons explained here. Neither of these changes is a sure-fire fix. I'm more suspicious about bypass caps and power, and the clock signal.

The Schmitt trigger is certainly worthwhile -- your Signal Generator needs to provide crisp transitions.

You should probably consider debouncing the reset signal, BTW. There are some suggestions in Garth's primer, here.

-- Jeff


Attachments:
6502BreadboardSchematic mod-1.png
6502BreadboardSchematic mod-1.png [ 1.49 MiB | Viewed 1386 times ]

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Wed Jun 24, 2020 3:15 pm 
Offline

Joined: Tue Jun 23, 2020 7:34 pm
Posts: 5
Dr Jefyll wrote:
Yes, this is certainly important. It's not a good sign that you were "measur[ing] high frequency oscillations between 0 and 5v on all the data lines and address lines."
" :shock: " Indeed... I don't think that was caused by noise, maybe my ground probe was detached or something, although I find that unlikely.

I should note that this breadboard version and the schematic I posted of it isn't really similar to what I have soldered, it was just a test to see whether my ic's were broken or not and whether I was still able to create a minimal working system.
The clock on the soldered version comes from a 1mhz can oscillator, so I assume that should provide a clean clock signal. It has worked before anyways. I also made a simple reset circuit that not only should provide a clean reset signal, it also provides two reset signals, so you can make sure that the IO resets before the 6502.

BigEd wrote:
So, clock and power are well worth getting very clean

Dr Jefyll wrote:
I'm more suspicious about bypass caps and power, and the clock signal

I did take care during soldering of ensuring good power and ground connections, as well as 100nf bypass capacitors, so I think that shouldn't be a problem. The power supply is a simple 2n3055 emitter follower to step down 12v to stable 5v, along with a 1000uf electrolytic capacitor. I'll try however whether I can measure any significant noise.

Dr Jefyll wrote:
On older 65xx systems it was SOP to take the Phi2 and /Phi2 signals from the outputs on pin 39 and pin 3 of the 6502
I believe I did once try to get the phi2 for the 6522 from the phi2 output of the 6502, but that didn't work, so I then decided to just use it directly from my clock.

Since I got a computer up and running before soldering one, I can rule out most possiblities. That means that the problem should be a soldering error or something that I have changed. I triple checked every connection and possible shorts, so I don't think there is a soldering error. The only things I changed were the memory map, the reset circuit and the power supply. I have confirmed the reset circuit works. The power supply also works, but it may be noisy, so I will try powering the computer from my bench power supply. At first I also did make a dumb mistake in the memory map, as I reserved 48K of RAM for a 32K chip :lol: . If it can be of use, I'll draw up a schematic of the memory map.


Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Wed Jun 24, 2020 9:35 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3363
Location: Ontario, Canada
I have a feeling you'll be able to sort this out with the techniques you're already familiar with, such a ROM that's full of NOP's.

As for the power supply, it seems to me it'd be easier to install a 7805 regulator and be done with it than to prove (using a low-bandwidth scope) that the other arrangement is noise free. Edit: but at least an emitter follower isn't prone to oscillate, the gain is so low.

fvp wrote:
I did take care during soldering of ensuring good power and ground connections, as well as 100nf bypass capacitors, so I think that shouldn't be a problem.
Just a reminder that wiring practices also play a role, beyond the actual soldering. The physical arrangement of the wires is important -- their length, the routes they follow, and where the bypass caps are located. If you continue having difficulty then we'll want to see some photos of your project. And the appropriate schematic, too.

Have fun, and keep us posted!

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Thu Jun 25, 2020 9:55 am 
Offline

Joined: Tue Jun 23, 2020 7:34 pm
Posts: 5
Well, I solved my problems!

When I filled my EEPROM with just nop's, I was still measuring garbage on all the data and address lines (AKA "the high frequency oscillations").
I ruled out problems with the clock and power supply by using the ones I used for the breadboard test. I then ruled out the memory map by testing it on the breadboard version. What is left? Soldering of course...

And indeed, after not only checking for shorts between neighbouring pins and ground and vcc like I had done before, I also checked for shorts between áll the pins on the 6502. Turns out I had shorted A1 to A13 and D3 to A12. :oops:

I have my chips very close to each other, just one pin-size in between, and a bundle of 10 or so wires somewhere running in that tiny space. If you then try to solder a wire to one of the pins of a chip, what apparently sometimes happens is that that wire punctures a hole in the bundle of cables and melts the plastic because the wire heats up trough the soldering iron. So that has happened to me twice.

Anyway, I'm glad I found the problems, and thanks for your help!
I'll now to try to get the rest of the system working, and I'm also planning to add an lcd and a sd card. I'll make sure to post some pictures when it is done.

BTW, still curious: Is it normal that your 6502 gets warm? When I let mine sit for a minute, it isn't really pleasant to touch.


Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Thu Jun 25, 2020 10:12 am 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1373
Glad you have it sorted and working again.

NMOS parts will get warm. Per the datasheet from MOS, the 6502 will dissipate upwards of 700mw, so that can get warm over time. The NMOS 6522 is upwards of 1000mw (or 1-watt).

Switching to newer CMOS parts would be a plus... much less power, faster clock speeds and with the 65C02 many more useful instructions and addressing modes.

Good luck with the project.... keep the posts and pictures coming.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: Weird 6502 problems
PostPosted: Thu Jun 25, 2020 10:12 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10821
Location: England
Too hot to touch is unusual, I'd say. Perhaps you have another short somewhere?

When making a PCB, or when a design is fully socketed, it can be a good investment to visit every pin with a continuity tester: test that the pin is connected to what it should be, and also that it isn't connected to what it shouldn't - by which I mean testing for shorts to adjacent pins and to power and ground, to keep it manageable.

Once the ICs are part of the circuit, continuity testing might or might not still be practical: I can imagine you might get leakage paths which give you false positives.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 22 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: