Flexible clock circuit
Flexible clock circuit
Hi All,
I'm aware this is not a 6502 specific question but I thought I could get good answers from here.
I am looking for a clock circuit that would allow me to select clock frequencies in a wide range including step by step operations. Ideally, I would want it to be able to work in 3 possible modes. (1) Full speed, possibly driven by a crystal oscillator. (2) Adjustable slow speed, in the range of almost zero to just few Hz, which I guess can be achieved with a 555 based circuit. (3) Step mode, where single pulsations of a push button will make the clock cycles.
I have found some easy designs on the internet (most of them based on the Ben Eater series nowadays), but all of them seem to overlook the possible bad effects of switching modes while in operation. For example, when the clock is switched from step mode to low speed mode, it is desirable that the circuit waits for the next clock edge before continuing with the selected frequency period. Also switching from slow speed to full speed modes should be seamless.
Thanks in advance for any pointers.
John
I'm aware this is not a 6502 specific question but I thought I could get good answers from here.
I am looking for a clock circuit that would allow me to select clock frequencies in a wide range including step by step operations. Ideally, I would want it to be able to work in 3 possible modes. (1) Full speed, possibly driven by a crystal oscillator. (2) Adjustable slow speed, in the range of almost zero to just few Hz, which I guess can be achieved with a 555 based circuit. (3) Step mode, where single pulsations of a push button will make the clock cycles.
I have found some easy designs on the internet (most of them based on the Ben Eater series nowadays), but all of them seem to overlook the possible bad effects of switching modes while in operation. For example, when the clock is switched from step mode to low speed mode, it is desirable that the circuit waits for the next clock edge before continuing with the selected frequency period. Also switching from slow speed to full speed modes should be seamless.
Thanks in advance for any pointers.
John
Re: Flexible clock circuit
Hi Joan,
I had to put together something like that to test the C74-6502. The clock circuit featured STOP/START, FAST/SLOW and STEP modes. The original circuit didn’t quite work, but I managed to patch it. Here’s a link to the relevant post on the thread.
viewtopic.php?f=4&t=3493&start=225#p54027
Hope that helps.
I had to put together something like that to test the C74-6502. The clock circuit featured STOP/START, FAST/SLOW and STEP modes. The original circuit didn’t quite work, but I managed to patch it. Here’s a link to the relevant post on the thread.
viewtopic.php?f=4&t=3493&start=225#p54027
Hope that helps.
C74-6502 Website: https://c74project.com
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Flexible clock circuit
I see Drass posted while I was writing. I'll keep going anyway.
I would recommend against using the 555, as its output rise and fall time are much too slow (100ns!) to meet the 65C02's requirements (if you were using a current-production '02). I don't have a full do-everything circuit for you, but I would base it on at least 74HC, if not 74AC, Schmitt-trigger logic. My 6502 primer's clock-generation page shows a single-cycler clock-generation circuit about 3/4 of the way down the page, and there are links there to related forum topics. See especially viewtopic.php?p=10619#p10619 where I show a variable-frequency oscillator I use. In viewtopic.php?p=378#p378, I tell of a couple of programmable oscillators from Dallas Semiconductor. (That was 16 years ago, so I'm sure they have improved ones by now.)
For clock stretching without glitches, see this experiment I did 21 years ago. (Don't use 4000-series logic though. I only used it because it's really slow, and I wanted it slow enough that if there were any runt pulses, they would show up on my 20MHz analog 'scope.)
I would recommend against using the 555, as its output rise and fall time are much too slow (100ns!) to meet the 65C02's requirements (if you were using a current-production '02). I don't have a full do-everything circuit for you, but I would base it on at least 74HC, if not 74AC, Schmitt-trigger logic. My 6502 primer's clock-generation page shows a single-cycler clock-generation circuit about 3/4 of the way down the page, and there are links there to related forum topics. See especially viewtopic.php?p=10619#p10619 where I show a variable-frequency oscillator I use. In viewtopic.php?p=378#p378, I tell of a couple of programmable oscillators from Dallas Semiconductor. (That was 16 years ago, so I'm sure they have improved ones by now.)
For clock stretching without glitches, see this experiment I did 21 years ago. (Don't use 4000-series logic though. I only used it because it's really slow, and I wanted it slow enough that if there were any runt pulses, they would show up on my 20MHz analog 'scope.)
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: Flexible clock circuit
Hi Garth,
The single-pulse circuit I used is taken from your clock generation page (although I mentioned it was yours, I failed to include a link in the schematic
).
I also used your VFO circuit when building my own, so I can vouch for it.
The single-pulse circuit I used is taken from your clock generation page (although I mentioned it was yours, I failed to include a link in the schematic
I also used your VFO circuit when building my own, so I can vouch for it.
C74-6502 Website: https://c74project.com
Re: Flexible clock circuit
Drass wrote:
Hi Joan,
I had to put together something like that to test the C74-6502. The clock circuit featured STOP/START, FAST/SLOW and STEP modes. The original circuit didn’t quite work, but I managed to patch it. Here’s a link to the relevant post on the thread.
viewtopic.php?f=4&t=3493&start=225#p54027
Hope that helps.
I had to put together something like that to test the C74-6502. The clock circuit featured STOP/START, FAST/SLOW and STEP modes. The original circuit didn’t quite work, but I managed to patch it. Here’s a link to the relevant post on the thread.
viewtopic.php?f=4&t=3493&start=225#p54027
Hope that helps.
I figured out that I could combine that with the ideas on your circuit, and I came up with this logisim simulation:
There are two clock input sources and a manual tick button:
- The fast clock source will be a crystal oscillator.
- I want the slow source to be variable along the few Hz range (maybe up to 10 Hz or so), so I think the 555 timer circuit described in the "digital computer electronics" book should do it.
The circuit seems to work fine on logisim although the clock exchange takes some time because it does not happen until both sources have completed its own cycle. That's not a major issue for me though. The circuit uses quite a number of ics but I assume it can't be simplified given the specs.
Joan
Re: Flexible clock circuit
GARTHWILSON wrote:
I see Drass posted while I was writing. I'll keep going anyway.
I would recommend against using the 555, as its output rise and fall time are much too slow (100ns!) to meet the 65C02's requirements (if you were using a current-production '02).
I would recommend against using the 555, as its output rise and fall time are much too slow (100ns!) to meet the 65C02's requirements (if you were using a current-production '02).
Thanks
Joan
Re: Flexible clock circuit
(Just possibly worth picking gates with Schmidt inputs, if the input is slow, and you really don't want glitches.)
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Flexible clock circuit
joanlluch wrote:
Thanks for the tip. I only aim for very slow clock rates (in the range of just a few Hz) for the 555 based source. I think that if I connect the output of the 555 to a flip-flop I will get a perfect square wave with proper edges and half the frequency, no?. A Ben Eater video on youtube shows an even simpler approach that seems to work. He just directly connects the 555 output to a few logic gates he uses for switching purposes, and then uses the output of that gates to clock a 6502. Is there something inherently wrong with that?
So we have to find a balance between, on the one hand, overburdening the beginner with excessive and complicated implementation details, and on the other hand, ignoring those and letting him build something that takes months to debug and he finally gives up. The goal of course is to maximize the success rate.
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?
- BigDumbDinosaur
- Posts: 9425
- Joined: 28 May 2009
- Location: Midwestern USA (JB Pritzker’s dystopia)
- Contact:
Re: Flexible clock circuit
joanlluch wrote:
- I want the slow source to be variable along the few Hz range (maybe up to 10 Hz or so), so I think the 555 timer circuit described in the "digital computer electronics" book should do it.
A problem with using a 555 timer, as previously mentioned, is the output transition time is much too slow for the 65C02. Also, you need to try for 50/50 symmetry, which is hard to attain from a relaxation oscillator.
Something I use in some of my designs that require a slow but stable symmetric "tick" is a comparator oscillator, such as the below illustration.
This particular application is a model railroad grade crossing signal flasher, with the comparator oscillator cycling the signal lights at the rate of 1 Hz. The circuit has near-perfect symmetry and is relatively insensitive to Vcc.
The circuit works because the input transition threshold of a comparator is extremely narrow, at most a few millivolts. Hence the oscillation frequency is a function of the R-C time constant of R5 and the C4/C5 combination. R5 is both charge and discharge path for the capacitors, which means symmetry is as good as that of the comparator "crossover" characteristics. The ratio between R4 and R5 is not critical, so you could use a pot in place of R5 to create a low-speed variable clock.
The comparator’s output is an open collector, so it has to be pulled up to Vcc—anything from 1K to 4.7K is usually sufficient. Open collector outputs are somewhat on the slow side, relatively speaking, with a high-to-low transition typically around 1 µS. A Schmidt trigger, such as a 74AC14, should be used to condition the oscillator’s output so as to satisfy the 65C02’s Ø2 clock requirements.
Last edited by BigDumbDinosaur on Fri Jul 18, 2025 4:53 pm, edited 1 time in total.
x86? We ain't got no x86. We don't NEED no stinking x86!
Re: Flexible clock circuit
BigDumbDinosaur wrote:
... you need to try for 50/50 symmetry, which is hard to attain from a relaxation oscillator.
Re: Flexible clock circuit
Agree with Ed (above).
And, as for 555 or a discrete circuit, it occurs to me that 74HC221 or '123 would be much better choices, given that they belong to the 74xx family. And, a quick check shows their output rise/fall spec (22 ns, assuming a 50 pF load) is roughly equal to that of an 'HC14 Schmitt Trigger, suggesting the latter will not be required or helpful for conditioning the output.
But even the 'HC14 isn't clearly within spec for driving a 65xx clock input. The 'HC specs don't tell us what the figure is for loads less than 50 pF.
-- Jeff
And, as for 555 or a discrete circuit, it occurs to me that 74HC221 or '123 would be much better choices, given that they belong to the 74xx family. And, a quick check shows their output rise/fall spec (22 ns, assuming a 50 pF load) is roughly equal to that of an 'HC14 Schmitt Trigger, suggesting the latter will not be required or helpful for conditioning the output.
But even the 'HC14 isn't clearly within spec for driving a 65xx clock input. The 'HC specs don't tell us what the figure is for loads less than 50 pF.
-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html
Re: Flexible clock circuit
Would something like the 74HC40103 work to clock a 65xx? That'd get you 8 bits of digital control over your clock speed, and you wouldn't have to mess with capacitances/resistances or carefully twiddle a pot.
Re: Flexible clock circuit
Hi Jeff,
I am not going to drive a 6502 with it, but a home made cpu, but I suppose this should make little difference. (The build thread describing the architecture and software tools I implemented is this: http://anycpu.org/forum/viewtopic.php?f=23&t=583)
The only purpose of such ultra low frequency mode is having visible blinking lights on the front panel showing registers and control line values. I though a 555 configured as a astable multivibrator with a potentiometer, followed by a J-K flip flop to obtain proper edges and 50% duty cycle, would do it just fine, as I do not need any frequency accuracy for that. I can also insert a Schmidt trigger buffer before the J-K as suggested.
Please can you point me to a circuit schematic that would do a 50-50 square signal with continuously adjustable frequencies in the range of a few Hz (such as from 0.25Hz to 10Hz) using one of the ics you suggest?
Thanks.
I am not going to drive a 6502 with it, but a home made cpu, but I suppose this should make little difference. (The build thread describing the architecture and software tools I implemented is this: http://anycpu.org/forum/viewtopic.php?f=23&t=583)
The only purpose of such ultra low frequency mode is having visible blinking lights on the front panel showing registers and control line values. I though a 555 configured as a astable multivibrator with a potentiometer, followed by a J-K flip flop to obtain proper edges and 50% duty cycle, would do it just fine, as I do not need any frequency accuracy for that. I can also insert a Schmidt trigger buffer before the J-K as suggested.
Please can you point me to a circuit schematic that would do a 50-50 square signal with continuously adjustable frequencies in the range of a few Hz (such as from 0.25Hz to 10Hz) using one of the ics you suggest?
Thanks.
Re: Flexible clock circuit
I apologies I haven't read all of this thread, just jumping in 
If i would need such a low frequency oscillator I would use a CMOS (hex) schmitt trigger inverter (40106 or 4584) with a large resistor or trim pot (2.5 or 5 M) wired from output to input and an (tantal) elco e.g. 47uF/10V or more.
To obtain lower frequencies (and square waves) a 4024 (2^7) or 4040 (2^12) binary counter could be used.
If you need fast rise/fall times a 74HC4040 should work as well.
If i would need such a low frequency oscillator I would use a CMOS (hex) schmitt trigger inverter (40106 or 4584) with a large resistor or trim pot (2.5 or 5 M) wired from output to input and an (tantal) elco e.g. 47uF/10V or more.
To obtain lower frequencies (and square waves) a 4024 (2^7) or 4040 (2^12) binary counter could be used.
If you need fast rise/fall times a 74HC4040 should work as well.
- GARTHWILSON
- Forum Moderator
- Posts: 8773
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Re: Flexible clock circuit
GaBuZoMeu wrote:
I would use a CMOS (hex) schmitt trigger inverter (40106 or 4584) with a large resistor or trim pot (2.5 or 5 M) wired from output to input and an (tantal) elco e.g. 47uF/10V or more.
I was going to post links to NSC (later Fairchild) ap. notes, but when ON Semi took over Fairchild, they wiped them out. I've been able to get them to re-post some of them, and now I just sent another email asking for these two, which I have old links to on my 6502 primer's clock-generation page and just realized I still need updated links to:
HCMOS crystal oscillators (AN-340) and
CMOS oscillators (AN-118)
I have them on paper but unfortunately not in electronic form to attach here. I plan to update this (as well as the links on my website) when I hear back from ON Semi.
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?