6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 14, 2024 6:46 am

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Jan 27, 2021 2:09 am 
Offline

Joined: Tue Oct 08, 2013 5:40 am
Posts: 72
Location: /home/sci4me
(Fair warning: I'm not an electrical engineer, just a hobbyist; programmer by day)

So, I recently built a rev2 PCB of a 65C02 system I built not too long ago. The changes made were fairly minimal (you could argue I was overly-eager to spin a board, but hey). Mostly just bug fixes, and adding a couple of extra I/O connectors and a power switch.

First boot attempt I discovered that I had forgotten to switch the clock driving everything but the CPU to use the actual clock rather than the PHI2 output from the 65C02, so I fixed that with a bodge wire on the back. At this point things seem to be working almost perfectly, but there's some garbage data showing up on the 7-segment displays. Seems like it's always one or two extra bits getting set (segments lighting up) and it seems to be deterministic.

Then I ended up realizing that changing the clock speed affected the behavior. Every slower clock speed I've tried (1, 2, 4, 8, 10 MHz) also displays the corrupted data in the LEDs but to my utter disbelief, running it at 12 MHz "fixed" the corrupted data.

I have already spent a fair bit of time going over the connections for the LEDs, re-soldered the joints, verified continuity and checked for shorts, replaced the latches, and found nothing wrong. Unfortunately I don't have an oscilloscope currently so I haven't been able to actually see what any of the signals are looking like.

But it's strange that everything else on the computer would work perfectly on the first try and this issue would magically go away by increasing the clock speed. I was actually expecting the opposite effect, if anything.

Any thoughts or ideas on this would be appreciated! :)


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 27, 2021 6:12 am 
Offline

Joined: Mon May 25, 2015 1:12 pm
Posts: 92
Do you have a schematic we could see?


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 27, 2021 2:13 pm 
Offline

Joined: Tue Oct 08, 2013 5:40 am
Posts: 72
Location: /home/sci4me
DigitalDunc wrote:
Do you have a schematic we could see?


Sure thing. I've attached a PDF. Only difference is that I have already corrected the clock signal thing in the PDF as I did with the bodge wire on the back of the board.


Attachments:
navi65-prototype-2.pdf [387.66 KiB]
Downloaded 66 times
Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 27, 2021 2:19 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8483
Location: Midwestern USA
sci4me wrote:
DigitalDunc wrote:
Do you have a schematic we could see?

Sure thing. I've attached a PDF. Only difference is that I have already corrected the clock signal thing in the PDF as I did with the bodge wire on the back of the board.

Could you please post a monochrome schematic?

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 27, 2021 2:47 pm 
Offline

Joined: Tue Oct 08, 2013 5:40 am
Posts: 72
Location: /home/sci4me
BigDumbDinosaur wrote:
sci4me wrote:
DigitalDunc wrote:
Do you have a schematic we could see?

Sure thing. I've attached a PDF. Only difference is that I have already corrected the clock signal thing in the PDF as I did with the bodge wire on the back of the board.

Could you please post a monochrome schematic?


Sure. Just out of curiosity, how come? Just easier to read?


Attachments:
navi65-prototype-2-mono.pdf [374.1 KiB]
Downloaded 53 times
Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 27, 2021 7:45 pm 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 1043
Location: near Heidelberg, Germany
My datasheets say that the 'HC11 is an AND with three inputs, Phi2 among them. The output goes to a 'HC574 that takes its data at the _rising_ edge of its CLK input. But that would be of the leading edge of the signal coming out of the AND.

You should use a NAND instead, that rises its output at the trailing edge of Phi2, where the actual data is on the bus. Or did I miss anything?
Or rather, use an OR with three inputs, so you only need to invert Phi2.

_________________
Author of the GeckOS multitasking operating system, the usb65 stack, designer of the Micro-PET and many more 6502 content: http://6502.org/users/andre/


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 27, 2021 7:54 pm 
Offline

Joined: Tue Oct 08, 2013 5:40 am
Posts: 72
Location: /home/sci4me
fachat wrote:
My datasheets say that the 'HC11 is an AND with three inputs, Phi2 among them. The output goes to a 'HC574 that takes its data at the _rising_ edge of its CLK input. But that would be of the leading edge of the signal coming out of the AND.

You should use a NAND instead, that rises its output at the trailing edge of Phi2, where the actual data is on the bus. Or did I miss anything?
Or rather, use an OR with three inputs, so you only need to invert Phi2.


I think your logic seems reasonable, that I should really be triggering the latches on the falling edge, if I'm understanding the write cycle timing correctly.
But this makes little sense to me because I never had this problem before on the previous revision of the board which used the same circuit to drive the latches as well as the same address decoding.

EDIT: Reading from here: https://wilsonminesco.com/6502primer/addr_decoding.html It says "You must have a way to make sure RAM cannot be written to when phi2 is low!" Does this imply that writes _should_ be qualified by the rising edge of phi2?

EDIT2: I'm not an expert but it seems like qualifying on the rising edge of phi2 is right. "... its bus accesses (reading or writing) when phi2 is high."


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 27, 2021 10:38 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
sci4me wrote:
EDIT: Reading from here: https://wilsonminesco.com/6502primer/addr_decoding.html It says "You must have a way to make sure RAM cannot be written to when phi2 is low!" Does this imply that writes _should_ be qualified by the rising edge of phi2?

EDIT2: I'm not an expert but it seems like qualifying on the rising edge of phi2 is right. "... its bus accesses (reading or writing) when phi2 is high."

The RAM's WE\ is level-sensitive, not edge-sensitive. It's not that data are transferred at the edge, but rather that the entire time that WE\ is low, you're writing to the RAM; and it will take on any and all values written to the specified address(es), as many times as they may change in that time, but quits accepting updates when WE\ rises. It's more like a transparent latch rather than an edge-triggered register. When it's all handled correctly, the WE\ won't go down until after the address becomes valid and stable, which is why you must wait until phase-2 is high. The data won't be valid yet, and the RAM will take in whatever is on the data bus; but at least you're not writing to an unintended address, and the data will be valid for the required setup time before WE\ rises.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 27, 2021 10:51 pm 
Offline

Joined: Tue Oct 08, 2013 5:40 am
Posts: 72
Location: /home/sci4me
GARTHWILSON wrote:
sci4me wrote:
EDIT: Reading from here: https://wilsonminesco.com/6502primer/addr_decoding.html It says "You must have a way to make sure RAM cannot be written to when phi2 is low!" Does this imply that writes _should_ be qualified by the rising edge of phi2?

EDIT2: I'm not an expert but it seems like qualifying on the rising edge of phi2 is right. "... its bus accesses (reading or writing) when phi2 is high."

The RAM's WE\ is level-sensitive, not edge-sensitive. It's not that data are transferred at the edge, but rather that the entire time that WE\ is low, you're writing to the RAM; and it will take on any and all values written to the specified address(es), as many times as they may change in that time, but quits accepting updates when WE\ rises. It's more like a transparent latch rather than an edge-triggered register. When it's all handled correctly, the WE\ won't go down until after the address becomes valid and stable, which is why you must wait until phase-2 is high. The data won't be valid yet, and the RAM will take in whatever is on the data bus; but at least you're not writing to an unintended address, and the data will be valid for the required setup time before WE\ rises.


Thanks for clarifying this!

So, a theory: the latches are edge-triggered so they're latching in the data on the bus before it's valid? However, this doesn't seem to add up, again, because the exact same circuit worked just fine on rev1. And I still have little idea why speeding it up "fixes" it. Perhaps the faster speed prevents this problem by causing the data to be valid earlier? I don't know, doesn't really add up to me.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 27, 2021 11:32 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8540
Location: Southern California
I can't really take the time to go through a schematic that's really not a schematic but just a netlist written around boxes; so this may or may not relate directly to your problem. But to answer the other parts, the gated latch is not edge-triggered, and an edge-triggered latch is not gated. It's kind of like the difference between taking a picture with a strobe flash in a pitch-black room, versus turning a light on or off at a particular time. Wikipedia tells about the various kinds at https://en.wikipedia.org/wiki/Flip-flop_(electronics) . The problem with allowing the RAM's WE\ to go low before phase 2 rises is that the address is not guaranteed to be valid and stable before R/W goes to the "write" position. The result is that you could be writing to an address which is not the valid one yet.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 28, 2021 12:05 am 
Offline

Joined: Fri Dec 21, 2018 1:05 am
Posts: 1114
Location: Albuquerque NM USA
Please show a picture of your board. I'm interested in speed of your parts and power & ground distribution. If not a 4-layer board with power & ground planes, tack on a few short power & ground wires from CPU to memory to I/O can be helpful. Is your 12MHz clock physically different clock than others (1,2,4,8,10Mhz)? I'm wondering about symmetry, rise time of the clock as well as the high/low levels. I'm new to 6502, but the recent few weeks of experience have shown that W65C02 needs bypass and 10uF filter cap close to its power/ground pins.
Bill


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 28, 2021 3:51 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8483
Location: Midwestern USA
sci4me wrote:
BigDumbDinosaur wrote:
Could you please post a monochrome schematic?

Sure. Just out of curiosity, how come? Just easier to read?

I'm partially color-blind.

Turning to your problem and as Garth notes, you need to qualify the write-enable on the SRAM with Ø2. 6502-family MPUs do their data transfers when Ø2 is high. Hence /WE should not be asserted while Ø2 is low, as the data bus is not guaranteed to be stable during that time. If you directly wire RWB to /WE you will likely violate the SRAM's timing and possibly corrupt data.

Note however that best system performance at any given clock rate will be achieved when the glue logic asserts the relevant chip select while Ø2 is still low. In other words, you should avoid using Ø2 to qualify chip selects.

GARTHWILSON wrote:
I can't really take the time to go through a schematic that's really not a schematic but just a netlist written around boxes...

Garth brings up something on which some expansion is worthwhile.

The purpose of an electrical schematic is to not only show how different circuit elements are interconnected, but to illustrate in "shorthand" how the circuit is supposed to function. That latter feature is defeated with excessive use of net symbols. To the maximum extent possible, you should draw out the actual connections as wires (or buses, although I personally find buses confusing at times and don't use them), limiting the use of net symbols to connections that go off-page. Such an arrangement is especially beneficial when illustrating cascaded logic. The reader, assuming s/he knows what the various logic symbols mean, will have an easier time of it figuring out what the circuit is supposed to do.

Schematics tend to be easiest to read if monochromatic, with black on a white background. Certain color combinations that look okay on a monitor screen can be a problem to clearly distinguish on paper, even for those with completely normal color vision. I can't speak for the others here, but I see no value in using color in schematics.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 28, 2021 3:54 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8483
Location: Midwestern USA
sci4me wrote:
EDIT: Reading from here: https://wilsonminesco.com/6502primer/addr_decoding.html It says "You must have a way to make sure RAM cannot be written to when phi2 is low!" Does this imply that writes _should_ be qualified by the rising edge of phi2?

EDIT2: I'm not an expert but it seems like qualifying on the rising edge of phi2 is right. "... its bus accesses (reading or writing) when phi2 is high."

See below...

Attachment:
File comment: Read/Write Qualified with Ø2
read_write_qualify_alt.gif
read_write_qualify_alt.gif [ 46.98 KiB | Viewed 748 times ]

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 28, 2021 5:39 am 
Offline

Joined: Fri Dec 21, 2018 1:05 am
Posts: 1114
Location: Albuquerque NM USA
sci4me wrote:
So, a theory: the latches are edge-triggered so they're latching in the data on the bus before it's valid? However, this doesn't seem to add up, again, because the exact same circuit worked just fine on rev1. And I still have little idea why speeding it up "fixes" it. Perhaps the faster speed prevents this problem by causing the data to be valid earlier? I don't know, doesn't really add up to me.


I'm tracing through your long decoding path for the seven-segment displays; it starts from address [15..8] through 74HC30, through two cascaded 74hc137, then an inverter, then 74hc11. Finally the output of 74hc11 is used to clock 74hc574 latch on the rising edge of CLK. On paper this won't even work because data is not ready at the rising edge of CLK. Only reason it did kinda work is because the long propagation delay has caused several glitches after the rising edge of CLK that managed to clock in the real data. The fix is shorten the prop delay and latch data on the falling edge of CLK.
Bill


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 28, 2021 7:06 pm 
Offline

Joined: Tue Oct 08, 2013 5:40 am
Posts: 72
Location: /home/sci4me
Thanks for all the comments so far. I totally agree about the schematic; this was the first one I'd worked on in a while, and the most complex one I'd ever worked on. Since then I've found myself wanting to clean it up and put it on one page, etc. Just haven't done so yet.

The long propagation delay being the reason it works in rev1 seems logical but doesn't necessarily explain why it doesn't work the same way in rev2. Still seems weird to me.

I'm actually working on building another system on a breadboard to be able to experiment more with things so I'll definitely try out the suggestions here. It confused me that I should latch data on the falling edge of CLK since it was stated that /WE should not be asserted while CLK is low, but it seems to make sense since the data should be valid at that falling edge and shortly after it.

I've attached a picture of the board layout in my CAD program as well as a picture of the board itself.


Attachments:
n65_r2_1.png
n65_r2_1.png [ 695.86 KiB | Viewed 697 times ]
Snapchat-824037782.jpg
Snapchat-824037782.jpg [ 1.42 MiB | Viewed 697 times ]
2021-01-19_15-03_1.png
2021-01-19_15-03_1.png [ 146.57 KiB | Viewed 697 times ]
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 13 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:  
cron