Page 1 of 1
clock issues
Posted: Fri Jul 01, 2022 5:20 pm
by djenn
I am following Ben Eaters 6502 project and build the clock and connected an w65c02 and the resistors on the databus for the NOP command (without eeprom or ram I'm still waiting for those components).
When monitoring the "program" running with an Arduino i noticed that the cpu executes each instruction twice.
Even if stepping manual through the program I must push the cock button twice before the cpu advances one instruction.
To be sure I connected leds to the adress lines d0..d3 so i could see the adress bus advancing and i have to push the clock button twice.
I checked all the connection multiple times and far as I can see everything is connected as it should.
I've tried shorter and longer clock pulses whitout succes, the pulses themself are clean, no rebounce whatsoever (impossible they come from 555 timer).
Is there something else i can try to solve this riddle?
Re: clock issues
Posted: Fri Jul 01, 2022 5:40 pm
by tmr4
When monitoring the "program" running with an Arduino i noticed that the cpu executes each instruction twice.
Even if stepping manual through the program I must push the cock button twice before the cpu advances one instruction.
It's not executing twice, the NOP instruction just takes two clock cycles to execute. That's just the way Ben's monitor works. He mentions this at 25:03 in his first 6502 video.
Re: clock issues
Posted: Fri Jul 01, 2022 5:50 pm
by BigDumbDinosaur
I am following Ben Eaters 6502 project and build the clock and connected an w65c02 and the resistors on the databus for the NOP command (without eeprom or ram I'm still waiting for those components)...I've tried shorter and longer clock pulses whitout succes, the pulses themself are clean, no rebounce whatsoever (impossible they come from 555 timer).
Firstly, all 65xx instructions require a minimum of two clock cycles to execute. As TMR4 said, NOP is a two-cycle instruction, which explains what you are seeing.
Secondly, the 555 is not a good clock source for any WDC device, as the 555 cannot meet the 65C02's requirement for clock rise and fall time (5ns maximum). For testing purposes you could run your clock signal through a 74AC14 or 74AHC14 Schmitt trigger, which will transform the somewhat lazy output of the 555 into a sharp and well-defined clock, although not necessarily symmetric.
Re: clock issues
Posted: Fri Jul 01, 2022 6:26 pm
by BigEd
Welcome, djenn! As noted, you'd be well-advised to look at a table of opcodes - how many bytes, how many cycles.
Re: clock issues
Posted: Fri Jul 01, 2022 8:13 pm
by GARTHWILSON
Welcome.
If you want to see it advance one address per clock cycle, use something like LDA #$A9. (The LDA# op code is also $A9.) The load-immediate instructions are among the two-byte, two-cycle instructions.
And I concur that a 555 is not a suitable clock driver for the W65C02S. It may work; but since it doesn't even come close to meeting the data sheet's requirements, it's just that it's not guaranteed to work.
Re: clock issues
Posted: Sat Jul 02, 2022 5:51 am
by djenn
Thank you all for helping me out!
It's clear to me now, whitout looking at the instruction set I assumed that a nop instruction was a one cycle instruction.
And while I'm waiting for the memory chip i cannot run a real program to see the difference.
The 55 is slow indeed, I'll add an hc414 for to be sure.
Re: clock issues
Posted: Sat Jul 02, 2022 6:19 am
by BigDumbDinosaur
The 55 is slow indeed, I'll add an hc414 for to be sure.
HC414? What I recommended is either a 74AC14 or a 74AHC14. 74HC is too slow.
Re: clock issues
Posted: Sat Jul 02, 2022 9:18 am
by djenn
The 55 is slow indeed, I'll add an hc414 for to be sure.
HC414? What I recommended is either a 74AC14 or a 74AHC14. 74HC is too slow.
I meant to write that, i guess I was not fully awake.
Re: clock issues
Posted: Sat Jul 02, 2022 11:34 am
by Michael
It looks like someone modified the Arduino sketch (program) to monitor a new connection from the SYNC pin on the 65C02 so that the Arduino Mega will display the opcode mnemonic during the SYNC (opcode fetch) cycle.
link:
https://github.com/dpm-343/6502-monitor
Re: clock issues
Posted: Fri Jul 08, 2022 8:21 am
by Aloha6502
Thank you all for helping me out!
It's clear to me now, whitout looking at the instruction set I assumed that a nop instruction was a one cycle instruction.
And while I'm waiting for the memory chip i cannot run a real program to see the difference.
The 55 is slow indeed, I'll add an hc414 for to be sure.
viewtopic.php?f=1&t=7117
These quick reference charts show you the clock cycles.
Note the caveat about this being NOT the 65c02.
But close enough for the purposes of understanding this concept.
The "C" column shows clock cycles for each instruction.