Why does A0 toggle at 1/2 the speed I expect?

Building your first 6502-based project? We'll help you get started here.
Post Reply
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

Why does A0 toggle at 1/2 the speed I expect?

Post by cbmeeks »

I have my 65C02 wired up to a breadboard.

I have RDY, IRQB, NMIB, etc. pulled high through a 3.3k resistor.

I have the data bus wired to $EA.

My scope is on A0.

For my clock, I have a 3.579545 MHz crystal cocking a 74HC4040 counter. From the counter, Q0 is outputting half that at 1.7897725 MHz (within the limitation of my breadboard).

That 1.79MHz clock is then fed to PHI2 to the 65C02. Now, I thought A0 would be half that at 895kHz or so. But instead, it's 446.4kHz which is half again.

What gives? Is it because the NOP takes two cycles and the program counter "stalls" during those two cycles?

Any information would be appreciated.

But at least I can see the PC is working. :-D

Thanks
Cat; the other white meat.
User avatar
Michael
Posts: 633
Joined: 13 Feb 2013
Location: Michigan, USA

Re: Why does A0 toggle at 1/4th the speed I expect?

Post by Michael »

Here's an R65C02 reset cycle as monitored by a PIC microcontroller which is single-cycling the R65C02. The first column shows 'R' for 'read', the second column is the contents of the address bus, and the third column is the contents of the data bus (supplied by the PIC at the point when the reset vector is being read). I regret not collecting the <sync> pin status which would have shown the instruction 'fetch' cycles.

Hope this helps...

Cheerful regards, Mike
Attachments
6502 reset.png
6502 reset.png (8.08 KiB) Viewed 1441 times
nyef
Posts: 235
Joined: 28 Jul 2013

Re: Why does A0 toggle at 1/2 the speed I expect?

Post by nyef »

cbmeeks wrote:
What gives? Is it because the NOP takes two cycles and the program counter "stalls" during those two cycles?
Yes, the NOP takes two cycles. During cycle one, it fetches the NOP instruction. During cycle two, it does the no-operation and fetches (and discards) the next instruction. Then, on cycle three, it fetches that next instruction again (repeating cycle one). Repeat to nausea.

For a two-cycle instruction that increases the program counter once per cycle, try something like BIT #imm. Or, since you're on a 'C02, there are some single-cycle NOPs available.
User avatar
GARTHWILSON
Forum Moderator
Posts: 8773
Joined: 30 Aug 2002
Location: Southern California
Contact:

Re: Why does A0 toggle at 1/2 the speed I expect?

Post by GARTHWILSON »

or even something like LDA#$A9 which takes two bytes and two clocks.
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?
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

Re: Why does A0 toggle at 1/2 the speed I expect?

Post by cbmeeks »

Thanks for the suggestions.

It's clear to me now why I am getting the results that I am. Learn something new every day. :-)

Next step is to get an actual EEPROM running some real code.....probably blinking some LED's through a VIA.

After that, a serial connection.

Then, on to some music with an AY-3-8912. :-D
Cat; the other white meat.
Post Reply