6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 2:30 am

All times are UTC




Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: 'BE' usage question
PostPosted: Sun Jul 11, 2021 9:33 am 
Offline

Joined: Sun Jul 11, 2021 9:12 am
Posts: 155
Hi Guys!

I have started playing around with the W65C02 at a low clock speed and a basic circuit consisting of essentially the CPU rom and clock (just 1 Hz). All is going well so far, with just a simple routine of reset vector pointing to $C000 and a jump command looping back to $C000. Monitoring it with a logic analyser shows that it's doing what it should.

I am now attempting to run the circuit by having the BE pin go high on the positive phase of the clock, making the CPU go into high Z on the negative phase (so I can make another circuit use the RAM/ROM on the low phase - like what the C64 did with the VIC2 chip).

I can see that it is going through the reset sequence correctly and can see that the ROM has $00 $C0 at the reset vector, but right after that it goes straight to address $0000 and not $C000. If I tie the BE pin high, then reset, it works correctly.

I read in the timing that it needs 30nS for things to become valid on the W65C02, so I added an inverter and cascaded the inverters to give a ~54ns delay.

Here the 1Hz clock is being fed to BE and tapped from there through the inverter chain and fed in to PHI2 on the W65C02, in an effort to keep the timing happy, but the problem still remains, the addresses the CPU requests are inconsistent (after the reset process settles down).

Again, I can tie BE high, reset the CPU and all is happy.

Are you not able to use BE in this manner? I know the CPU starts setting up the address in the low cycle and was hoping it would merely keep the address lines in high-z. Or does BE low also stop the CPU for doing things internally?

I can look at adding a few buffer chips if needed between the CPU and address bus if this method won't work.

Love to hear your thoughts. Many thanks in advance. :D


Attachments:
2.png
2.png [ 15.46 KiB | Viewed 1017 times ]
1.png
1.png [ 54.64 KiB | Viewed 1017 times ]


Last edited by J64C on Mon Jul 12, 2021 10:23 pm, edited 1 time in total.
Top
 Profile  
Reply with quote  
 Post subject: Re: 'BE' usage question
PostPosted: Sun Jul 11, 2021 11:17 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Welcome! I suspect you need to look at the falling edge of phi2 - that's where the interesting stuff happens. The CPU needs to see valid data from the ROM at and around that edge. If you're dropping BE early, before that edge, you might well be disturbing things.


Top
 Profile  
Reply with quote  
 Post subject: Re: 'BE' usage question
PostPosted: Sun Jul 11, 2021 11:33 am 
Offline

Joined: Sun Jul 11, 2021 9:12 am
Posts: 155
Hi there! Thanks for the reply. Funnily enough, I was just reading this page (https://laughtonelectronics.com/Arcana/ ... iming.html) and realised exactly what you just said, that the data is read all the fall of phi2. Previously I figured it must have been happening mid clock cycle.

I have pull down resistors on the address and data lines, so I’m suspecting that it is reading the reset vector as $0000. Even though my logic analyser is reading correct data in the reset vector as $C000, as it’s reading the data shortly after the phi2 goes high.

I’ve packed up for the night, so I’ll make some adjustments in the morning and let you know. Exciting times! Having great fun here. This is something I’ve wanted to do since I was a kind in the 80’s! Hehe!

Thanks again! Will let you know how it all goes.


Top
 Profile  
Reply with quote  
 Post subject: Re: 'BE' usage question
PostPosted: Sun Jul 11, 2021 11:36 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Glad you're enjoying the adventure! Did you add the pulldowns because you found you needed them, or because it was recommended somewhere? It's an unusual choice.


Top
 Profile  
Reply with quote  
 Post subject: Re: 'BE' usage question
PostPosted: Sun Jul 11, 2021 3:47 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8544
Location: Southern California
Keep in mind also that the address and R/W must be valid and stable before the rise of Φ2. Certain I/O ICs require this, with a set-up time, and you'll want to make sure you don't write to unintended addresses in RAM as well. I have not looked at how various computers did the two-accesses-per-cycle thing, but I'll be interested to see the developments here. Especially as you turn the clock speed up, I suspect some interesting clock duty-cycle schemes will come into play. [Edit: Jeff has an excellent way to put it, a couple of posts down.]

_________________
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  
 Post subject: Re: 'BE' usage question
PostPosted: Sun Jul 11, 2021 4:06 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Hmm, I think I'd put that just a little differently, although the effect might be the same.

First, if you happen to be using one of the chips which uses the rising edge of phi2, then you need its inputs to be stable before then.

And secondly, for writes to be safely written to the correct locations, you need the addresses to be stable before write enable becomes active.

(If that's not right, let me know and I'll rewrite it - or retract it!)


Top
 Profile  
Reply with quote  
 Post subject: Re: 'BE' usage question
PostPosted: Sun Jul 11, 2021 4:47 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
GARTHWILSON wrote:
I suspect some interesting clock duty-cycle schemes will come into play.
That thought struck me, too.

To perform an access, a memory (or IO) device wants to see two parts to the cycle: an inactive time during which its address inputs stabilize (satisfying the setup time), then an active portion during which an actual transfer (such as a write) occurs.

Normally these correspond to the 65xx's Phi2-low and Phi2-high phases -- the two phases "add up" to one complete access. But, doubling that up to accomplish two accesses (by two devices), I think you'll want each of the 65xx's phases split in half so the memory or IO device still gets two parts to every cycle (as described above). IOW, four phases altogether:

- setup time for access 1
- data transfer for access 1
- setup time for access 2
- data transfer for access 2

-- 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: 'BE' usage question
PostPosted: Sun Jul 11, 2021 6:00 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Of possible interest, the insides of the Oric Atmos, a 6502 machine:
http://oric.free.fr/HARDWARE/timing.gif
http://oric.free.fr/HARDWARE/ula.html


Top
 Profile  
Reply with quote  
 Post subject: Re: 'BE' usage question
PostPosted: Sun Jul 11, 2021 10:48 pm 
Offline

Joined: Sun Jul 11, 2021 9:12 am
Posts: 155
Wow! What an amazing community. I go to be and wake up to all this info! Huge thanks to you all. :D

Yeah, I do realise I'll be up against quite a few timing constraints with what I am attempting to do, with keeping R/W, address, and data states legal. I'll be re-reading through these posts and putting the puzzle pieces together bit by bit, hitting each problem as is comes along. I think half the fun of projects like this is the challenge itself and as much as it is the end result.

The reason for the pull down resistors, was more so I could get things to a known state (using pull ups where that default is better suited). So pull down is unusual? What's the norm, pull up? Or just none at all?

Thanks once again too! It is amazing to see the enthusiasm in this community. I truly wasn't expecting this. Most corners of the internet seem to be filled with 'gatekeepers' and other unpleasant types these days. I can already feel this place is something special!


Top
 Profile  
Reply with quote  
 Post subject: Re: 'BE' usage question
PostPosted: Sun Jul 11, 2021 11:59 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8544
Location: Southern California
J64C wrote:
The reason for the pull down resistors, was more so I could get things to a known state (using pull ups where that default is better suited). So pull down is unusual? What's the norm, pull up? Or just none at all?

On the buses, none at all. But when there are pull-___ resistors on something, it's normally pull-up, because so many devices could pull down much harder than up, and could not pull up to a valid logic 1 against a pull-down resistor very well. Back to the buses though: WDC's processors can pull up just as hard as down; but that's not true of some SRAMs' data outputs for example.

_________________
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  
 Post subject: Re: 'BE' usage question
PostPosted: Mon Jul 12, 2021 12:29 am 
Offline

Joined: Sun Jul 11, 2021 9:12 am
Posts: 155
Ah! Very good point.

As mentioned, they are mainly there to give a known good state on my early prototype board. I had some issues early on where I had the last address pin floating on the RAM (128K chip) and it was giving odd results, as you'd expect. But yes, I could just as easily tie that last pin high, through a resistor. Through a resistor as I don't want it permanently 'high' as I am using the same RAM on a VGA board that I made.

Which brings me back to my motives of running the CPU on one phase. My plan is to run my VGA board on the low phase (inverted), so they can share the same RAM at the same time. :D

So in the end, I can probably discard the resistors on the address and data lines.

BTW, now got this bad boy running on one phase (only 60Hz) as I type this. 8) CPU is just reading at the moment though, to I still have a way to go. Just running the following code.

Code:
*=$C000
     JMP *


Nothing too exciting, but it seems stable at the moment.

[edit]
Current timing in the pic below. All working well, but haven't attempted to perform any writes on RAM yet, which I'll expect I'll have to make further 'enhancements'.

BTW, what's the preference on this forum regarding progress pic/info? Happy for me to post in this thread as I go? Or is that a 'no no'?


Attachments:
3.png
3.png [ 13.22 KiB | Viewed 1017 times ]


Last edited by J64C on Mon Jul 12, 2021 10:24 pm, edited 1 time in total.
Top
 Profile  
Reply with quote  
 Post subject: Re: 'BE' usage question
PostPosted: Mon Jul 12, 2021 1:50 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8544
Location: Southern California
Keep in mind the RxC (resistance times capacitance) time constant (TC) with pull-___ resistors. Say for example you have a bus capacitance of 35pF and a 4.7K resistor. That makes for a TC of 164ns, which won't get you anywhere in a half a clock period when you go to 10MHz for example. 10MHz has a half period of 50ns, less than 1/3 of the TC. This kind of thing is why WDC put a totem-pole driver on the IRQ\ output of their W65C22S to make sure it's high again before the return-from-interrupt instruction finishes, so the processor doesn't immediately go right back into the interrupt-service routine (ISR). This is illustrated in the second diagram in my 6502 interrupts primer (although there it's using the 2V NMOS VIH threshold instead of the 70% Vcc CMOS VIH). I got bit by this on a Rockwell '22 in the 1980's even at a very low clock speed when I was trying too hard to save power and made the pull-up resistor way too high.

It's also why the popular I²C 2-wire interface is much slower than SPI. I²C uses pull-up resistors, and each device has only open-drain (or open-collector) outputs, and to get a logic 1, these output transistors must be off in order to let the pull-up resistors make the line float up. The resistors pull up, and bus contention between devices does not result in excess current. I²C never goes more than a few megabits per second (Mbps), and it's usually well under 1Mbps. SPI OTOH does not have any bi-directional lines, so it can use totem-pole outputs, meaning there's virtually no speed limit, and some devices have approached 100Mb/s.

J64C wrote:
BTW, what's the preference on this forum regarding progress pic/info? Happy for me to post in this thread as I go? Or is that a 'no no'?

A few forum members have used a single topic as an incremental progress blog for their project, reaching 40+ pages, which is fine. If the subject changes completely, it might be good to start another one; but if you have a bunch of different related ones for the same project just to keep them shorter, it may become harder for a new or casual reader to appropriately tie them together in his mind when one depends on the other. If you make separate ones like that, and they depend on each other, please add links in each one to the other.

_________________
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  
 Post subject: Re: 'BE' usage question
PostPosted: Mon Jul 12, 2021 2:10 am 
Offline

Joined: Sun Jul 11, 2021 9:12 am
Posts: 155
Thanks once again for the info there. Funnily enough, Western Design Center recommended your site to me themselves over on Twitter. 8)

Tons and tons of awesome information. You have done extremely well!

I'm now attempting to perform writes on RAM, which seems to be working to an extent. But then the program counter goes off in to cyberspace somewhere, shortly after the write. About to step through and see if the opcodes and operands are what they should be (might have a loose address or data line - or could be completely something else.

Code:
*=$FFFC
       byte $00,$C0


*=$C000
        ldx #$00
loop
        stx data
        inx

        lda data
        clc
        cmp #10
        bne loop

        jmp $C000

data   
        byte $00


If my coding is correct, it should be storing a value at 'data', incrementing it (which I can see that it is) and looping somewhere around the $C0xx area depending on the branch test. But, presently it jumps somewhere seemingly random shortly after the write to 'data'.


Top
 Profile  
Reply with quote  
 Post subject: Re: 'BE' usage question
PostPosted: Mon Jul 12, 2021 2:14 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
GARTHWILSON wrote:
J64C wrote:
The reason for the pull down resistors, was more so I could get things to a known state (using pull ups where that default is better suited). So pull down is unusual? What's the norm, pull up? Or just none at all?

On the buses, none at all. But when there are pull-___ resistors on something, it's normally pull-up, because so many devices could pull down much harder than up, and could not pull up to a valid logic 1 against a pull-down resistor very well. Back to the buses though: WDC's processors can pull up just as hard as down; but that's not true of some SRAMs' data outputs for example.

Further to what Garth said, it appears just about all of the presently-available SRAMs and ROMs produce TTL-level outputs, not CMOS. This raises an interesting problem with a 65C02 or 65C816 running on five volts.

According to information provided by Bill Mensch (the 65C02 and 65C816 designer), the input transition point for both MPUs is at 50 percent of Vcc. In other words, an input on an MPU operating on five volts would need to see at least 2.5 volts to recognize the input as a valid logic 1. Testing done by forum member Dr. Jefyl indicates that that number is closer to 2.7 volts.

Devices with TTL-level, totem-pole outputs are theoretically capable of driving a load to about 3.4 volts maximum, based on a theoretical diode drop of 0.8 volts—one drop occurs in the topmost output transistor and the other drop occurs in the leveling diode that is in series with the two output transistors. However, loading will quickly drag down the logic 1 voltage. Hence TTL outputs are only guaranteed to reach 2.4 volts when outputting a logic 1. Therefore, use of a pullup resistor helps in this regard because, as Garth noted, TTL outputs are better able to sink than source. The resistor assists the device in driving its output higher.

See also Garth's comments about the effects of bus capacitance and resistor values. In using pullup resistors, I generally go for the lowest value possible consistent with the weakest device's ability to sink current. That strategy reduces the R-C time-constant to some degree, which may help with trying to run the system faster.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: 'BE' usage question
PostPosted: Mon Jul 12, 2021 2:23 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
J64C wrote:
BTW, what's the preference on this forum regarding progress pic/info? Happy for me to post in this thread as I go? Or is that a 'no no'?

I attach images and other files to posts—that way they will be there for the life of the post. It's better that way than linking to off-site locations. Images load more quickly and the reader doesn't have to go to another location to see things.

As Garth said, adding on to a topic is the preferred method if the topic doesn't meander too much. My POC V1 topic runs to some 32 pages, which have accumulated over a period of about 12 years. Some things that I developed as part of the POC V1 project were broken off into separate topics because they were of a more general nature.

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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

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