Clock out

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

I've set the clock out fuse (1284p @ 16mHz) in order to watch the signal, non-prescaled. Only as a matter of hobby interest, but was very surprised to see a slightly dirty +ve sine wave.

Is it normal to use this signal 'as is' to drive other chips clock's or gate it to produce a square wave?

I'm also seeing 6v pk-pk although the supply is a pretty ripple free 5v, is this normal also?

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

what are you using to observe this signal. If it is a scope probe, how long is the ground lead and where is it connected?

Jim

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

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

Both good points Jim. The gnd lead was about 8 inches from the probe tip, I've fixed that schoolboy error. My other mistake was using sample mode. I've since set that to average 64 readings and now it's a much cleaner sine wave and the pk-pk is a more sensible 5.2v
However, I still would have thought it would be a square wave, not a sine?

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

Would have expected something more square, also. Do you have any bandwidth limiting on the scope? Does the scope averaging reduce the bandwidth?

Jim

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

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

I don't believe so, there's nothing in the manual. I've found out what caused the +ve offset though! The ISP lines were still hooked up :oops:
However, it's still a sine wave?

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

Is probe set to x1 or x10 ?

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

x1 originally, then upp'd to x10. Same result. The oscillator output on PB1 is most definitely a sine wave ;) Now just need to understand the 'why'.
Conversely, the output of the clock out on a DS1307+ (on the same board, is a perfect square wave. Go figure...

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

You don't say so, but I presume you have a crystal in circuit. The waveform is usually roughly sinusoidal across a crystal, though it does depend to some extent on the drive circuit. In the AVR I believe this is a CMOS gate with feedback running as an analog invertor. If you want to use the output to drive external circuitry you should use an external schmidtt buffer to square it up.

Regarding the DS1307, I take it the "clock out" means pin 7? This is a buffered digital output. If you put a scope on one of the crystal leads you'll be lucky to see anything, the signal level is so low, but it is in fact approximately a sine wave.

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

Quote:
You don't say so, but I presume you have a crystal in circuit
Indeed, a 16mHz with caps. Yes, if I probe the watch crystal, it stall's (not surprising).
Quote:
If you want to use the output to drive external circuitry you should use an external schmidtt buffer to square it up.
This is what I thought.
Quote:
In the AVR I believe this is a CMOS gate with feedback running as an analog invertor.
Hence the sinusoidal waveform? Is there mention of this in the datasheet? I'm not curently planning on using this signal, the experimentation was for edutainment.
Thanks :)

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

gregsmithcts wrote:
Is there mention of this in the datasheet?

Yes, in the "System Clock" section.

Quote:
Pins XTAL1 and XTAL2 are input and output, respectively, of an inverting amplifier which can be configured for use as an On-Chip Oscillator..

There are two of them, one low power and one high power, selected by fuse.

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

Hmmm..... I was thinking your were talking about CKOUT pin, but the Mega1284 does not have one. So, it must be the physical oscillator output. Not so surprising that its close to sinusoidal. The general practice, pre-CE/FCC was to run those inverters harder so that they were hard-clipped. Now, to reduce EMI, they don't do that.

You can just feed that signal into a single-gate inverter, not bothering with Schmitt Trigger. That will square it up pretty well, with rise and fall each representing 10-20% iof the period.

Jim

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

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

No, I was refering to the clock output buffer on CLKO (PB1)...

Quote:
The device can output the system clock on the CLKO pin. To enable the output, the CKOUT
Fuse has to be programmed. This mode is suitable when the chip clock is used to drive other circuits
on the system. The clock also will be output during reset, and the normal operation of I/O
pin will be overridden when the fuse is programmed. Any clock source, including the internal RC
Oscillator, can be selected when the clock is output on CLKO. If the System Clock Prescaler is
used, it is the divided system clock that is output.

There is no mention (I can see in the datasheet) of needing to condition this signal? As you can tell, I was expecting it to be a square wave. Peret has now cleared up the confusion.
Thanks everyone. Something else learned (the hard way) ;)

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

https://www.avrfreaks.net/index.p...

That thread started about the STK600 but I did some scoping on a mega88 with CLKO enabled: pin14 is shown in the pictures

Edit: CLKO-fuse on the mega88 is not he same as the CKOPT in other devices. Anyway, justed wanted to show you the pictures I made recently.

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

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

Thanks.
It was that thread that prompted my interest in looking at my clock :)

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

ka7ehk wrote:
I was thinking your were talking about CKOUT pin, but the Mega1284 does not have one.

This is named CLKO and it is physically located at PB1 pin. Clock overrides normal PB1 pin functionality when the fuse is programmed. OP reports it does not look like technically digital, but more like analog output. Like XTAL2..

@gregsmithcts
If you want to measure the frequency of running quartz, then just place the proble close to inverter's output (XTAL2) but do not touch it directly...

With 16MHz sine.. My first thought was that the scope attenuates higher frequencies of 16MHz sqare wave... And sine comes out.
What is the analog bandwidth of your scope?

No RSTDISBL, no fun!

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

Quote:
What is the analog bandwidth of your scope?
It's only a cheap 25mHz job. But it's no so cheap as to not be able to differentiate an analogue sine wave from a digital square wave :)
I'm happy with the explanation I've received. The output on PB1 is an amplified and 180 degree phase shifted version of the crystal input, which is sinusoidal. If I want to use it for anything in the future I'll gate it, as originally I thought I'd need to.

Quote:
If you want to measure the frequency of running quartz, then just place the proble close to inverter's output (XTAL2) but do not touch it directly...
I'll give that a try next time I get my test gear out - thanks. (Pushed for space, I need to put everything away once I've finished working/playing)

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

A 16MHz square wave is composed of 16MHz, 48MHz, 80MHz, 112MHz, with amplitude 1, 1/3, 1/5..

Since you filter off the harmonics, you are left with the 16MHz part, so that is what you see.
You need at least a 50MHz scope and probe to see anything but a sine, and 100MHz before it could look square-ish.

/Kasper

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

Certainly, with a 25 MHz scope, you will loose most of the harmonics, but there should be some evidence of "flat tops". The 48MHz harmonic will be reduced by several db compared to its normal value. In fact, the 16MHz signal will be reduced by 1-2db db compared to its "real" value.

Unless the frequency response is sharper than a single-pole (that is, like a single RC lowpass). it has 3db loss at 25MHz, and about 1db at 12.5MHxz (1/2 the corner frequency). It will have about 7db loss at 50MHz (2x corner frequency). 6db means that the "gain" is about 0.5. In other words, that 48MHz 3rd harmonic will be half the amplitude it should be if it were a perfect square. Thee will still be enough to make some "squareness". It should be enough to obviously not be "sine".

Jim

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

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

If somebody with a 100mHz scope would care to do the trace, and post it here, I may be convinced to dig deeper into my pockets ;)

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

A 25MHz scope will work good until about 1/3rd(every scope has this feature) of its max freq, so your 25MHz scope will effectively be showing 'lies' as from 8,3MHz.

Note that you probably also have a bad slewrate. What are the specified slewrates of the rising and falling edge. It might be just as well that your scope just can not follow the fast rising flank.
By using averaging you only mask this problem.

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

Quote:
It should be enough to obviously not be "sine".
All this presupposes that the signal is square to start with.
Next week (unless somebody traces it with 100mHz scope) I'll put the signal through a gate (and force it to be square) and trace the resulting waveform. If as has been suggested, my scope is not upto the job, that too will show up as a sloppy sine. If however, that shows as a square wave, others here will have to rethink their posisitions.

As previously noted, I'm a hobbiest, not an EE and all of this this is a learning experience. Clearly not all the views expressed in this thread can be correct.

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

Or perhaps use different(slower) crystal/RC/divider for measurements. If PB1 circuitry is analog with 16MHz quartz, it will be analog with 1MHz quartz either.

No RSTDISBL, no fun!

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

Brutte wrote:
Or perhaps use different(slower) crystal/RC/divider for measurements. If PB1 circuitry is analog with 16MHz quartz, it will be analog with 1MHz quartz either.

Good point, however, 16mHz is the slowest I have, and I can't get back to it until next week :)

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

I made some snapshots with Tek TDS2022, 200MHz, no Bandwidth limiter, 100MHz 10x probe; STK600 with ATmega88V in DIP-socket; Xtal = 8MHz

1_low_power_8MHz_xtal2.jpg: fuses high 0xDF | low 0xBD

2 full_swing_8MHz_xtal2.jpg: fuses high 0xDF | low 0xB7

With CLKO enabled (= buffered):
3___pin14_header.jpg: low power or full swing has no influence on this signal: note the over- and undershoot
4___pin14_close to AVR.jpg: same conditions as 3, but now measured as close as possible to the DIP AVR.

Attachment(s): 

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

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

and 2 more pictures

Attachment(s): 

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

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

Thanks Plons 1_low_power_8MHz_xtal2.JPG is pretty much what I saw before using the averaging function on my scope.
Most certainly not a square wave!

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

I would disagree. That looks much more like a filtered square wave than a sine wave to me.

Edit: Use Matlab to plot a fourier expansion of a square wave with only the first two terms, and see what you get. Always tough to tell w/ digital scopes exactly what you are measuring (one argument to use analog scopes for slow signals like this). Here's a matlab plot of what I was describing:

Attachment(s): 

Science is not consensus. Science is numbers.

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

10MHz out of an ATMega168 seen with a 250MHz scope and 10x probe.

This scope+probe should be able to show 1.4 ns risetime, and has proven to do so.
The rise time seen gere is 4.8 ns. Nice and slow.

/Kasper

Attachment(s): 

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

Looks more like square to me.. So CLKO is digital in here.

It is a well known fact, that IO drivers of AVRs have transistors of about 25 ohm resistance (both, at f=0). If those drivers are used to drive CLKO, and it takes them 4,8ns to charge the capacitances of a single IO, then (assuming first order RC step response, lets suppose 63% of 5V is made in ~2,5ns), we get:

R*C=2,5ns (IIRC the step response).
So C is about 1e-10F.
The power wasted@16MHz is: C*U^2*f=1e-10F*5V*5V*16e6Hz=40mW(as we need to recharge the cap twice per period). Is that about correct?

No RSTDISBL, no fun!

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

Direct measurement into a pin that is high impedance says 9.4 pF (yes I just did that).
The slew rate is a result of how hard/fast the output fets get driven, rather than the output capacitance.
sub-ns switching is not desirable unless you have something that needs it. It is power hungry, and noisy.

/Kasper

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

In the mega32 and 128, they said 'turn on CKOPT above 8MHz', and when I did that, I see a nice 5V pk to pk sq wave on X1. Fuse off is about a 1v pk to pk sine wave.

Imagecraft compiler user

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

Thanks guy's, I'm convinced! But not convinced enough to spend several thousand on a scope :)

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

Just to add another:

My latest little pcb (using a Mega324p) feeds the CLKO directly into the oscilator input of a MCP2515 CAN ic, and i am glad to report (as i hadn't buffered the output ;-) that the clock signal is a nice square wave even at 20MHz !! (measured with a 200MHz Agilent scope and 10x low inductance probe)

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

As I've now installed the capture software on my Mac, I'm able to show the waveform that had me confused...

As I said, when I turned on averaging, this was represented as a sine wave.
Now I know better ;)

Attachment(s): 

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

This looks as if the scope is trying to do undersampling, combined with not triggering cleanly.
You SHOULD be able to get something that looks periodic, and not random-ish.

The upside about a real photo (or full screen capture) is that unlike the picture above, it contains the settings, or most of them. Your plot could also be produced by setting the time/div (and thus sampling rate) far too low. Then you get funny interference.

/Kasper

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

Remember, it's just a 25mHz scope. The upside of a File/Save Image, is that it just shows the wave form, not all the settings details :)
Timebase is 25us, 2V CH1. Matters not though, as it was the shape of the wave I was querying. Most other setting's result in a meaningless scrabble of junk ;)
As noted, I dont have the money for a 'good' scope, and as this trace is very similar to Plons' 100mHz trace (at least in my mind) I'm quite happy to plod along with what I've got until I win the lotto :)
Now, if I had a spare 5-10 thousand...
http://www.rapidonline.com/Tools-Fasteners-Production-Equipment/Test-Equipment/Oscilloscopes/LeCroy-WaveSurfer-44MXs-B-400MHz-4-channel-oscilloscope/400469

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!

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

Really, 800 BP is all it takes to get a decent scope for hobbypurposes. I bought mine way too late: when the hair was grey already. Same for a logic analyzer.
In this GE forum, several threads were dedicated to scope's and LA's

Nard

edit: this beauty for a bit more than a thousend pound:
http://cgi.ebay.co.uk/Rigol-Color-Oscilloscope-200MHz-4-CHs-DS1204B-2G-sample-/270406753202?pt=BI_Oscilloscopes&hash=item3ef57f9bb2

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tessa and Tina, You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

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

If you stumble upon an old analogue, and you have room for it, grab it. For certain signals it is just wonderful. Sure there are 5k BP scopes that do just as well.

Behold my old Philips scope. got it for 30 BP and it just needed a little care. 20ns/div.

/Kasper

Attachment(s): 

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

Quote:
and you have room for it
There in lies the big problem! The modern DSO's are so light/small/convenient, I can whip it out, have a fiddle... and put it back in it's box, before the wife realises I've destroyed the room with all my bit's...

Oh, for a large workspace, nicely organised, and all mine, Mine, MINE!!!

:)

--greg
Still learning, don't shout at me, educate me.
Starting the fire is easy; the hardest part is learning how to keep the flame!