Clocking external logic

Go To Last Post
19 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My AVR is using a 20MHz crystal. In addition, I have some external 74HC191 counters that need to be clocked with a 10MHz square wave.

Can I obtain a 10MHz, 0-5V square wave from the AVR's crystal somehow, or would I be better off using a 555 or a crystal oscillator module?

Edit: Looks like 10MHz is too high a frequency for a 555...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does your AVR have a clock out? If so that output will let you have the 20MHz signal out, use a counter to divide it down to 10MHz.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just use a flipflop to divide the buffered clock by 2...

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

kherseth wrote:
Does your AVR have a clock out? If so that output will let you have the 20MHz signal out, use a counter to divide it down to 10MHz.

Problem with using a counter is you will end up with something more like a sinewave than a square wave, being you only have 1 bit of resolution available.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Bullloooony!

Using one bit of a counter is no different from using a flip flop. That might be slightly true if a CD4xxx series counter is used in comparison to a 74HCxx flip flop but if you compare apples to apples by using a 74HCxx counter, there IS NO DIFFERENCE!

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My bad I was under the impression he meant using the AVR's counter. ;)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I might be using all my I/O pins, so I'm not sure I could use the clock output. If I can, I'll run it through a JK flip-flop like UNiXWHoRe suggested.

I did some more reading and it seems that I can't just get a square wave off one of the XTAL lines. So I'll probably use another oscillator. It shouldn't matter too much that the clocks won't be in sync.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

UNiXWHoRe wrote:
My bad I was under the impression he meant using the AVR's counter. ;)

Still bull!

The output of the AVR's counter, or an external counter is still a digital signal... if you want a sine wave, you need to add some filtering components to perform some wave shaping.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Autorelease,

I guess it goes without saying to carefully evaluate if you really need to run the micro at 20 MHz. If you can run it at 10 MHz then you only need one clock and things are simpler.

If you can use just 10 MHz then if you can re-do your design to free up the Clock Output Buffer pin, if your particular chip has one, it provides a buffered output of the clock, (10 MHz, in your case). As an example this is discussed in Section 8.10, (page 39), of the ATMega164P/324P/644P data sheet.

If that won't work there are many clock options, but one you might like to at least consider is the DS1077 8 pin chip. It is a programmable clock chip that, I believe, can put out TWO clock signals, for 8KHz to 133 MHz. It does not require an external crystal for itself. 0.5% Freq tolerance on +5V supply.

It is on my list of "Next chip to play with...", but I haven't gotten to it yet, myself.

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm very tired, so forgive me if I'm an idiot here, but what if you just toggled a bit on an output port every clock cycle? At 20 MHz it would rise, fall, rise, fall... etc with a 10MHz frequency between the rising edges. That would also keep it nearly perfectly in phase with the AVR clock (there is always a little propagation delay)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm trying to squeeze every bit of speed out of the processor, so I'm running it at 20MHz.

CodeMonkey263, if I toggled an output pin every clock cycle, I wouldn't be able to do anything else with the processor. Plus, extra cycles would be required for looping...

I went down to my local electronics store and bought a Bomar 10MHz crystal oscillator. It cost less than $2 and my circuit is working quite well with it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you use counter 1 in CTC mode with a count of 0 (I think - it's been a while. Might be '1') and 'toggle on OCR1A', it will output a signal at half the main clock frequency from OC1A/PD5 with no processor overhead.

Assuming you have the pin free, of course.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

glitch, CodeMonkey, and barnacle:

Try it, scope it, let me know how it looks. ;)

I have tried this before, I think the IO pin is just too slow at those speeds.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have, and the pins are plenty fine... check the capacitance of your probes!

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or, better yet, compensate your probe AND check the scope bandwidth. It needs to be at least 50MHz to show the logic outputs anything like they really are.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think it looks very pretty. The 1V to 4V transition takes 3ns, not too fast and not too slow, and the duty cycle is 50%+/-0,6%, the jitter is better than 200ps*, I can't find anything to complain about?

/Kasper

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hmm nevermind then... Maybe I did so on an older AT90 part? Oh well, apologies!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The older at90 parts could drive just as well as the current parts. I'd say the problem was how you went about measuring the waveform, and not the AVR.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've done it too using a timer and an interrupt. Since the timers are just counters, and the interrupts free my software to do whatever, it's almost as good as a counter/divider chip :)

Sorry I should have specified the counter/interrupt bit, I was tired...