6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed May 08, 2024 8:42 pm

All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: clock issues
PostPosted: Fri Jul 01, 2022 5:20 pm 
Offline

Joined: Fri Jul 01, 2022 4:15 pm
Posts: 5
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: clock issues
PostPosted: Fri Jul 01, 2022 5:40 pm 
Offline

Joined: Sat Feb 19, 2022 10:14 pm
Posts: 147
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.

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.


Top
 Profile  
Reply with quote  
 Post subject: Re: clock issues
PostPosted: Fri Jul 01, 2022 5:50 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8177
Location: Midwestern USA
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!


Top
 Profile  
Reply with quote  
 Post subject: Re: clock issues
PostPosted: Fri Jul 01, 2022 6:26 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
Welcome, djenn! As noted, you'd be well-advised to look at a table of opcodes - how many bytes, how many cycles.


Top
 Profile  
Reply with quote  
 Post subject: Re: clock issues
PostPosted: Fri Jul 01, 2022 8:13 pm 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8432
Location: Southern California
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.

_________________
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: clock issues
PostPosted: Sat Jul 02, 2022 5:51 am 
Offline

Joined: Fri Jul 01, 2022 4:15 pm
Posts: 5
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: clock issues
PostPosted: Sat Jul 02, 2022 6:19 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8177
Location: Midwestern USA
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!


Top
 Profile  
Reply with quote  
 Post subject: Re: clock issues
PostPosted: Sat Jul 02, 2022 9:18 am 
Offline

Joined: Fri Jul 01, 2022 4:15 pm
Posts: 5
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.

I meant to write that, i guess I was not fully awake.


Top
 Profile  
Reply with quote  
 Post subject: Re: clock issues
PostPosted: Sat Jul 02, 2022 11:34 am 
Offline
User avatar

Joined: Wed Feb 13, 2013 1:38 pm
Posts: 586
Location: Michigan, USA
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


Top
 Profile  
Reply with quote  
 Post subject: Re: clock issues
PostPosted: Fri Jul 08, 2022 8:21 am 
Offline

Joined: Wed Feb 17, 2021 6:54 am
Posts: 69
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.


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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

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