Strange memory write problems

Building your first 6502-based project? We'll help you get started here.
User avatar
Dr Jefyll
Posts: 3525
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: Strange memory write problems

Post by Dr Jefyll »

To me it's notable that, by mucking with GND/VCC distribution, we've produced a change in behavior. That seems like an indication that we're at least barking up the right tree. And of course that tree is GND/VCC noise, perhaps resulting from the very snappy rise & fall times on the outputs of the RAM and (especially) the WDC CPU.

But! Speaking of noise... here's a question which I'm embarrassed not to've mentioned sooner... :oops:

Have you tried adding pullup resistors on the data bus? The inputs (including the data bus) of WDC CPUs are not TTL compatible. In common practice, many hobbyists ignore this, and they (usually) get away with it because TTL-specced memories exceed their spec sufficiently that the system works anyway (albeit with reduced noise immunity). But you, Adrian, have perhaps not been so lucky... and your symptoms are consistent with a noise problem. Try adding eight pullup resistors, say 3.3k or 2.2k or even 1.5k.

Alternatively, is there any chance of replacing the WDC CPU with an older chip with slower rise/fall times such as a Rockwell R65C02? (It's also possible a slower RAM would help, but I suspect the WDC CPU is the noisiest rise/fall time offender.) Moreover, the inputs of Rockwell 65C02s (and most/all? other non-WDC 65C02s) are TTL compatible.

[Edits.]

-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
User avatar
CountChocula
Posts: 101
Joined: 07 Nov 2021
Location: Toronto, Canada

Re: Strange memory write problems

Post by CountChocula »

adrianhudson wrote:
I took the extra wires off and its back working again. How can that BE???

I am beginning to be seriously demoralised with this thing. :-(
Sorry this is giving you so much trouble! Do you have an oscilloscope? If so, this may actually be a stroke of luck—you can now reproduce the error much more easily, and if you can keep an eye on what's going on with your signal lines, you may also figure out what's going wrong. Maybe your supply is barely keeping up with the power demands of the circuit, and when too many chips take a gulp of power, it dips just enough for a runt pulse to happen, or something like that. I would definitely consider putting those wires back and taking a look. Good luck! I hope you figure this out soon :-)


—CC
adrianhudson
Posts: 169
Joined: 30 Apr 2022
Location: Devon. UK
Contact:

Re: Strange memory write problems

Post by adrianhudson »

Dr Jefyll wrote:
To me it's notable that, by mucking with GND/VCC distribution, we've produced a change in behavior. That seems like an indication that we're at least barking up the right tree.
Good point!
Dr Jefyll wrote:
Have you tried adding pullup resistors on the data bus? … Try adding eight pullup resistors, say 3.3k or 2.2k or even 1.5k.
Have added said resistors (2K2) and am running a test as I write this. Will leave it some hours before making any pronouncements!
Dr Jefyll wrote:
Alternatively, is there any chance of replacing the WDC CPU with an older chip with slower rise/fall times such as a Rockwell R65C02?
I don’t have an R65C02 but have just ordered one. It will be here in a couple of days.

I will keep the rewiring of power and ground as a last resort.

Jeff, thanks again for your thoughts. Sorry it’s a rushed reply but my Internet is playing up and I have typed this at least 5 times. Very irritating.
adrianhudson
Posts: 169
Joined: 30 Apr 2022
Location: Devon. UK
Contact:

Re: Strange memory write problems

Post by adrianhudson »

CountChocula wrote:
adrianhudson wrote:
...
Sorry this is giving you so much trouble! Do you have an oscilloscope? If so, this may actually be a stroke of luck—you can now reproduce the error much more easily, and if you can keep an eye on what's going on with your signal lines, you may also figure out what's going wrong. Maybe your supply is barely keeping up with the power demands of the circuit, and when too many chips take a gulp of power, it dips just enough for a runt pulse to happen, or something like that. I would definitely consider putting those wires back and taking a look. Good luck! I hope you figure this out soon :-)

—CC
Hi CC, thanks for always sounding so positive :-)
I'm going to do a bunch of things suggested by Dr Jefyll first. I do have a 'scope but its one of those handheld things that look like a large multimeter (it does that too). It has two channels but is I think, from memory, only a 40Mhz device so pretty limited. I have already been looking at the address and data lines with it but nothing looks terribly wrong to me. As I noted in my first post there is some crossstalk from the clock, but I don't think it is terribly bad, not enough to cause missreads of logic states... a l t h o u g h ... on thinking about it, Dr Jefyll has talked about the WDC CMOS devices being marginal vs TTL in this respect... so, lets see what his pullup resistor suggestion brings.
adrianhudson
Posts: 169
Joined: 30 Apr 2022
Location: Devon. UK
Contact:

Re: Strange memory write problems

Post by adrianhudson »

Dr Jefyll wrote:
...
That is one very useful post indeed!
I'm amazed, given the number of similar WDC C02 designs out there, that I haven't noticed anyone complaining about similar problems.
User avatar
Dr Jefyll
Posts: 3525
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: Strange memory write problems

Post by Dr Jefyll »

adrianhudson wrote:
I'm amazed, given the number of similar WDC C02 designs out there, that I haven't noticed anyone complaining about similar problems.
Well, in order to perceive a logic high, a WDC CPU powered by 5V needs to see at least 2.6V on its input. (That figure is experimentally derived, and may vary somewhat between specimens and according to temperature and so forth.) But any TTL-rated memory or peripheral will output a high of at least 2.4V, which is close.

And TTL-rated memories and peripherals typically do, for various reasons, output a logic-high voltage that exceeds the TTL spec. In fact they may exceed it substantially, but of course that's not guaranteed.

The bad news is, there'll always be a certain amount of noise imposed on the incoming signal and the VCC and GND lines, so you need some extra margin to afford a degree of noise immunity. IOW, it's not sufficient for the incoming logic high merely equal the WDC's 2.6V threshold.

We've seen that mucking with your GND/VCC network can have an effect on the outcome, but I don't believe the network is deficient, or at least not drastically so.

If you were out in a rowboat and you became concerned because there's occasionally a wave that splashes over the gunwale and into the boat, would you conclude that the waves are too high? Seeking calmer waters would help... but waves can't be avoided entirely. The root problem may simply be that your boat is riding too low in the water!

-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Strange memory write problems

Post by BigDumbDinosaur »

Dr Jefyll wrote:
The root problem may simply be that your boat is riding too low in the water!

...which will sink your design.

Sorry, Jeff...just couldn't help it. :lol:
x86?  We ain't got no x86.  We don't NEED no stinking x86!
adrianhudson
Posts: 169
Joined: 30 Apr 2022
Location: Devon. UK
Contact:

Re: Strange memory write problems

Post by adrianhudson »

BigDumbDinosaur wrote:

...which will sink your design.
OUCH!

Well, yesterday evening I put 8 2k2 resustors on the data lines and commoned them together to +5V. Things are very much better. In fact I have seen no data errors at all.

...however - the thing crashes after a random time (usually a few hours, though i have only tested it for 18 hours or so. I left it running overnight and it did 23,808 full scans of memory and then appeared to "stop". I reset it running and it did 3328 full scans of memory before stopping. I started it a while ago and it has done 7000 scans and is still going.

The program uses a few bytes of stack and 3 bytes at address $0000-$2000 - one pointer and a counter. I think that only the pointer becoming corrupted and pointing to the stack or the I-O area OR the stack itself becoming corrupted would cause the program to go out of control (the code is in ROM). At the moment I can't think of how to determine which happened.

Well, anyway, we are getting somewhere! I'm not quite sure where to go next though.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Strange memory write problems

Post by BigEd »

You can do wonders with a (very) cheap analyser and hoglet's decoder.
Quote:
This project enables a cheap (<£10) 16-channel USB logic analyzer to be used as an effective diagnostic tool for 6502-based computer systems
adrianhudson
Posts: 169
Joined: 30 Apr 2022
Location: Devon. UK
Contact:

Re: Strange memory write problems

Post by adrianhudson »

BigEd wrote:
You can do wonders with a (very) cheap analyser and hoglet's decoder.
Quote:
This project enables a cheap (<£10) 16-channel USB logic analyzer to be used as an effective diagnostic tool for 6502-based computer systems
Thanks for that BigEd. What a fantastic project!
User avatar
Dr Jefyll
Posts: 3525
Joined: 11 Dec 2009
Location: Ontario, Canada
Contact:

Re: Strange memory write problems

Post by Dr Jefyll »

adrianhudson wrote:
In fact I have seen no data errors at all.
Excellent news! More on that in a moment.
BigDumbDinosaur wrote:
...which will sink your design.
:| But, but, but.... <attaches image> ... the lower transistor is supposed to sink !

That's what causes the output to run aground ! :mrgreen:
sourcing and sinking.png
sourcing and sinking.png (3.46 KiB) Viewed 1295 times
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
adrianhudson
Posts: 169
Joined: 30 Apr 2022
Location: Devon. UK
Contact:

Re: Strange memory write problems

Post by adrianhudson »

Dr Jefyll wrote:
adrianhudson wrote:
In fact I have seen no data errors at all.
Excellent news! More on that in a moment.
BigDumbDinosaur wrote:
...which will sink your design.
:| But, but, but.... <attaches image> ... the lower transistor is supposed to sink !

That's what causes the output to run aground ! :mrgreen:
sourcing and sinking.png
Oh dear, oh dear oh dear!! ~sighs~
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Strange memory write problems

Post by BigDumbDinosaur »

Dr Jefyll wrote:
adrianhudson wrote:
In fact I have seen no data errors at all.
Excellent news! More on that in a moment.
BigDumbDinosaur wrote:
...which will sink your design.
:| But, but, but.... <attaches image> ... the lower transistor is supposed to sink !

That's what causes the output to run aground ! :mrgreen:
sourcing and sinking.png
I knew it! All I needed to do was make one little, inconsequential pun and Jeff would go into full Shakespeare mode, dive right in and spout a whole bunch of them. :lol:
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Strange memory write problems

Post by BigEd »

Quote:
Thanks for that BigEd. What a fantastic project!
I'd very much recommend you dive in - there's plenty of help available, and with a full trace of activity, I think I'm right in saying that an explanation has always been forthcoming as to what's going on, which usually leads to a fix. Even quite analogue kinds of problems will show themselves in the trace of activity, because what we end up seeing is the 6502's view of the world.
adrianhudson
Posts: 169
Joined: 30 Apr 2022
Location: Devon. UK
Contact:

Re: Strange memory write problems

Post by adrianhudson »

BigEd wrote:
Quote:
Thanks for that BigEd. What a fantastic project!
I'd very much recommend you dive in - there's plenty of help available, and with a full trace of activity, I think I'm right in saying that an explanation has always been forthcoming as to what's going on, which usually leads to a fix. Even quite analogue kinds of problems will show themselves in the trace of activity, because what we end up seeing is the 6502's view of the world.
I'm ahead of you. I have already placed an order for the hardware! :-)
Post Reply