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?
clock issues
Re: clock issues
djenn wrote:
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.
Even if stepping manual through the program I must push the cock button twice before the cpu advances one instruction.
- BigDumbDinosaur
- Posts: 9425
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: clock issues
djenn wrote:
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.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: clock issues
Welcome, djenn! As noted, you'd be well-advised to look at a table of opcodes - how many bytes, how many cycles.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: clock issues
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.
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.
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?
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?
Re: clock issues
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.
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.
- BigDumbDinosaur
- Posts: 9425
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: clock issues
djenn wrote:
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.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: clock issues
BigDumbDinosaur wrote:
djenn wrote:
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
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
link: https://github.com/dpm-343/6502-monitor
Re: clock issues
djenn wrote:
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.
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.
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.