Author Topic: Best way to get multiple clock speeds...  (Read 3398 times)

0 Members and 1 Guest are viewing this topic.

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Best way to get multiple clock speeds...
« on: May 11, 2018, 05:59:46 pm »
I am working on a Z80 vintage type project and I want to have multiple clock speeds.  An AVR will also be present, but it will be clocked at 14.7456M for clean serial port baud rate reasons.  I will use 3 pins to control the clock speed so 8 speeds, but 1 is dedicated for the AVR to manually clock it, so that leaves me 7 more speeds.  I wanted to pick speeds that the Z80 commonly ran with, and at the same time allow for maximum speed (20MHz).  Speeds that come to mind are 20, 16, 12, 10, 8, 6, 5, 4, 2.5, 2, 1 MHz, but I can't think of an easy way to be able to do them all.  The best way I've come up with is using a 74HC151 to select the 1 out of 8 clocks, and then use both sides of a 74hc393 counter to split two oscillators, one 20MHz and one 16MHz.  That would give me:

20, 10, 5, 2.5, 1.25
and
16, 8, 4, 2, 1

where I could tap 20, 16, 10, 8, 4, 2, and 1 as my seven speeds.

This would involve 2 oscillators, a 74HC393, and a 74HC151.  Is there a better way to do it?
 

Offline maginnovision

  • Super Contributor
  • ***
  • Posts: 1963
  • Country: us
Re: Best way to get multiple clock speeds...
« Reply #1 on: May 11, 2018, 06:08:58 pm »
A programmable pll might be a better choice for board space but possibly worse for cost. Be wary of all components being fast enough to keep up though and that you have a power supply that can supply the current as well.
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 4228
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: Best way to get multiple clock speeds...
« Reply #2 on: May 11, 2018, 06:23:36 pm »
I'd look at something like a Cypress CY22393F. Chips like this are designed to do exactly the sort of thing you're after.

They're not "vintage", of course, but only you know whether or not that matters.

Offline nuno

  • Frequent Contributor
  • **
  • Posts: 606
  • Country: pt
Re: Best way to get multiple clock speeds...
« Reply #3 on: May 11, 2018, 07:59:40 pm »
I think ZX Spectrum used ~3.54MHz
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #4 on: May 11, 2018, 09:31:36 pm »
That is quite an IC.  I need 5V though, but I don't care if the IC is vintage.  Any other ideas or thoughts?
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16611
  • Country: us
  • DavidH
Re: Best way to get multiple clock speeds...
« Reply #5 on: May 11, 2018, 11:36:27 pm »
Usually the problem is switching clocks without violating the clock specifications.
 

Offline C

  • Super Contributor
  • ***
  • Posts: 1346
  • Country: us
Re: Best way to get multiple clock speeds...
« Reply #6 on: May 12, 2018, 12:11:42 am »

I see this as most likely a waste of time.
I could see
full speed, slow for idiot lights & single step.

Max speed Z80 wants a square wave for signal. You get this by using the output of a FF. This can also prevent timing glitches on speed change.

If you want fancy then look at TTL delay lines as timing source for the clock.
This lets you have async clock source.
You could have different times for clock high vs clock low.
The taps on the delay line lets you create many different delays easily.

C
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #7 on: May 12, 2018, 12:42:23 am »
I think I can switch the clock between speeds safely when it is in BUSREQ or WAIT mode.  We'll see once I test it.  I am surprised there isn't a SPI clock generator that multiplies/divides one oscillator into other speeds!  The first IC looked pretty impressive, but only 3.3V and more complicated than needed!
 

Offline C

  • Super Contributor
  • ***
  • Posts: 1346
  • Country: us
Re: Best way to get multiple clock speeds...
« Reply #8 on: May 12, 2018, 01:06:09 am »

The Z80 is still using the clock during DMA & Wait.

Undefined is still undefined.
You need to switch clocks such that min time for clock level is valid.
Two clock sources makes this hard when clock sources are not locked and keep changing phase ratio.
A test that shows it works can fail as the two clocks change.


 

Offline Nitrousoxide

  • Regular Contributor
  • *
  • Posts: 156
  • Country: au
Re: Best way to get multiple clock speeds...
« Reply #9 on: May 12, 2018, 01:55:45 am »
You could possibly use a single higher frequency oscillator and then use a set of flip-flops to progressively divide the clock by 2, then by using a MUX you can tap off the desired clock. For example, a CD40175B and a DG441 could do the trick.

Or alternatively, you can use a counter. Just when the counter reaches the last value/overflows, you can load in a specific value to give you the desired period.
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #10 on: May 12, 2018, 03:22:46 am »
That is exactly what I am doing / planning on doing now.  I was just wondering if there was a more efficient less parts way to do it.
 

Offline David Hess

  • Super Contributor
  • ***
  • Posts: 16611
  • Country: us
  • DavidH
Re: Best way to get multiple clock speeds...
« Reply #11 on: May 12, 2018, 03:49:29 pm »
This article at EDN discusses the problem and some solutions.  The article below shows what I have done in the past to switch between multiple clocks.  The synchronous clocks are generated, a ripple counter works as shown but a synchronous counter might be needed if there are a lot of stages or the clock rate is high, and then "reclocked" using a flip-flop and the fastest clock so the output clock is always aligned with the fastest clock.  That gets you down to the divider, multiplexer, flip-flop, and gate so perhaps 4 or 5 packages.

Weird, I'm not sure why the PDF attachment failed.  Here is a link to it also.

« Last Edit: May 12, 2018, 07:18:01 pm by David Hess »
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #12 on: May 12, 2018, 05:24:49 pm »
Can you repost the pdf David, it is 0kb and can't open for me.  Thanks!
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #13 on: May 12, 2018, 05:29:35 pm »
That is a great article, but I wonder if it is necessary to prevent the tiny clock glitch in this example.  If the Z80 is in WAIT or BUSREQ mode, it is just watching clocks going by until either of these two signals de-asserts, so a glitch should not cause any trouble.  The only Z80 I plan on using is fully static and you can even stop the clock without any trouble.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14463
  • Country: fr
Re: Best way to get multiple clock speeds...
« Reply #14 on: May 12, 2018, 06:19:59 pm »
I don't know what kind of freq. accuracy you're after, but you could take a look at the LTC6903. You won't get the kind of accuracy you can get with a crystal-based oscillator, but it's very flexible.
http://www.analog.com/en/products/clock-and-timing/silicon-oscillators/ltc6903.html

« Last Edit: May 12, 2018, 10:38:17 pm by SiliconWizard »
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #15 on: May 12, 2018, 07:08:33 pm »
That is interesting.  I'm not so sure accuracy is huge though I'd prefer more than less.  Are there more accurate versions?
 

Offline C

  • Super Contributor
  • ***
  • Posts: 1346
  • Country: us
Re: Best way to get multiple clock speeds...
« Reply #16 on: May 12, 2018, 08:06:05 pm »

Until you know all the factors that effect each part of the logic inside a logic device, using it outside of specifications is just a guess that it will work. Your testing could show it works, but one of the many factors changing can make it fail. Did your test include all the many factors that can change?
Is it a good computer when it fails 1 time in a million or billion clock cycles?

Digital logic has an analog foundation.
Just because some logic works when you have two outputs driving a signal, does that say that it will always work? Well known that added stress can cause parts to fail sooner.
Do you want to add the added fun of trying to find why it failed in the future?

If the specifications do not mater then your 20mhz Z80 would run at 100mhz.

Two reasons for an accurate clock.
1. To keep timing margins on attached circuit with in limits.
2. To know how long a sequence of instructions will take. In the days of the Z80 many computer designs & min cost, put limits on max and min clock speeds.

I repeat, I see very little benefit with many clock speeds. 
You might change the speed to match what is attached to get max computing power.
 You might change the speed to allow better use of idiot lights on signals.
 You might single step or slow to help debug.

For Z80 the WAIT input is standard way to adjust speed to attached circuit. Z80 clock is a second way.

If a Z80 & attached circuit will function with some timing margin at speed X, what is the benefit of using anything less?

C

 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #17 on: May 12, 2018, 08:35:36 pm »
It is for a retro/vintage Z80 CP/M project so I may want to run old software slow, which is the reason for the multiple speeds.
 

Offline jimmc

  • Frequent Contributor
  • **
  • Posts: 304
  • Country: gb
Re: Best way to get multiple clock speeds...
« Reply #18 on: May 12, 2018, 08:56:57 pm »
If you've have spare capacity on the AVR to control it (I2C), how about a Si5351 https://www.silabs.com/documents/public/data-sheets/Si5351-B.pdf and choose any clock speed between a few kHz and >100MHz.
It will need a level shifter on the outputs. Breakout boards are available cheaply on ebay etc.

Jim
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14463
  • Country: fr
Re: Best way to get multiple clock speeds...
« Reply #19 on: May 12, 2018, 10:45:55 pm »
That is interesting.  I'm not so sure accuracy is huge though I'd prefer more than less.  Are there more accurate versions?

Unfortunately not. There are more sophisticated clock generators, but clearly overkill for your needs and expensive.

It has 0.5% initial accuracy and 1.1% max over the whole range according to the datasheet. I think it would fit the requirements of a vintage computer. 1.1% max error is fine for serial asynchronous communication for instance. It may be more problematic for video generation maybe? Although some vintage computers didn't use actual crystals for their main oscillator but ceramic resonators (much cheaper), which have the same range of accuracy than the IC I mentioned. (see: https://en.wikipedia.org/wiki/Ceramic_resonator )

If you still prefer a crystal-based oscillator, the 74LS294 seems interesting: http://www.ti.com/product/sn74ls294
It doesn't seem to be available in HC series though, and is hard to find except at TI? But worth a look for vintage stuff.
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #20 on: May 12, 2018, 11:56:17 pm »
That si5351 is interesting.  Do they have a SPI version of that?

I also need a 14.7456M oscillator for the AVR, I could use the si535 to produce both the Z80 clock and the AVR clock as long as I have a 3.3-5V translation for each of them.
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #21 on: May 13, 2018, 02:53:01 pm »
I've been playing around with the ClockBuilder for the si5351, it is pretty impressive what it does for its price and a 25 MHz crystal.  I wish I could get it to produce the 14.7456 MHz I need for the AVR too, but it sounds like unless you can't get them easily custom programmed.
 

Offline jimmc

  • Frequent Contributor
  • **
  • Posts: 304
  • Country: gb
Re: Best way to get multiple clock speeds...
« Reply #22 on: May 13, 2018, 03:39:48 pm »
The Si5351 clock outputs are 8mA into 50ohm ie 400mV pk so some form of line receiver might be the way to go to get to 5V.
The ebay breakout boards have level shifters for the inputs and a 3.3V regulator.
Maybe a second small AVR  (running on its internal oscillator) dedicated to programming  the Si5351.

Jim
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #23 on: May 13, 2018, 10:51:14 pm »
I'm already going to be using a sn74ahct1g125dbvr for another 3.3->5 conversion so I might just move to the quad version.

I noticed that the Si5351 talks about different drive strengths.  With a high impedance input, should it have a near vcc type output?
 

Offline bson

  • Supporter
  • ****
  • Posts: 2269
  • Country: us
Re: Best way to get multiple clock speeds...
« Reply #24 on: May 14, 2018, 03:41:55 am »
If you don't mind replacing the vintage RS-232 port with USB and using a CP2102N, then you could run the serial port at one of the supported data rates more easily generated, such as 125kbps.  That's just a 4MHz clock divided by 32.  Because, let's face it, that RS-232 port is going to have a USB adapter attached to it anyway...
« Last Edit: May 14, 2018, 03:43:37 am by bson »
 

Offline alank2Topic starter

  • Super Contributor
  • ***
  • Posts: 2185
Re: Best way to get multiple clock speeds...
« Reply #25 on: May 14, 2018, 03:56:58 am »
I'm going to run all the serial through the AVR - it has 4 ports and that is one of the reasons it will have a uart friendly oscillator (14.7456MHz).
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf