Page 1 of 1

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

Posted: Thu Apr 07, 2016 1:36 am
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

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

Posted: Thu Apr 07, 2016 1:54 am
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

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

Posted: Thu Apr 07, 2016 2:26 am
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.

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

Posted: Thu Apr 07, 2016 4:09 am
by GARTHWILSON
or even something like LDA#$A9 which takes two bytes and two clocks.

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

Posted: Thu Apr 07, 2016 12:57 pm
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