16MHz clock of the 328P MCU - how best to see it ?

I have a 30MHz oscilloscope ( in good working condition ) and would like to see the 16MHz clock waveform on a bare bone Atmega 328P running normally ( at least its blinking the LED at the expected rate ). I am using a 16MHz crystal and two numbers of 22pF capacitors.

Tried to see the waveform ( unsuccessfully ) on one of the crystal pins. Which would be the best way ? Is it possible to route the clock to one of the digital pins ?

Thanks

Mogaraghu:
Tried to see the waveform ( unsuccessfully ) on one of the crystal pins. Which would be the best way ? Is it possible to route the clock to one of the digital pins ?

Yep, just set the right fuse.

Easy way to do so is to create / edit boards.txt and copy and rename (or temp modify) the Uno lines of the fuses. Just past the fuses it uses now into an online fuse calculator and turn on "Clock output on PortB0" and use the fuses it has now in boards.txt. Then reburn the bootloader with the modified or edited board.

Visited the page you linked. Very nicely done. Thanks.

But it looks like its not for the weak of heart to monkey around with the fuse bits ....

If this is what it takes to route the clock to a port pin, I would tend to look at ways of directly probing it on the crystal pins.... Possible at all ?

Sure, you can examine the raw crystal signal pins - but it's not going to be the nice 5 volt peak-to-peak square wave that you'd get with the port output method. You'll see maybe a half volt or so ugly ac signal at the fundamental crystal frequency.

Also, your scope probe may have enough capacitance to possibly load the crystal circuit enough that it may cause things to stop oscillating - so don't be surprised if things suddenly stop working!

avr_fred:
Sure, you can examine the raw crystal signal pins - but it's not going to be the nice 5 volt peak-to-peak square wave that you'd get with the port output method. You'll see maybe a half volt or so ugly ac signal at the fundamental crystal frequency.

Also, your scope probe may have enough capacitance to possibly load the crystal circuit enough that it may cause things to stop oscillating - so don't be surprised if things suddenly stop working!

Great ... this is the response I was expecting. " ....ugly ac signal..." is what I was observing when probing the crystal pins and I thought the something is seriously wrong. In fact that signal is practically of no use since it looked more like noise than signal.

Ok now I have to learn how to mess with the bits and then burn the boot loader. Would be happy to get a Tutorial on this ... I am sure the Arduino ecosystem will sure have it some where ...

I never really figured out how to to do it the nice way with my own boards.txt, but if you edit the normal boards.txt ([Arduino install]\hardware\arduino\avr\boards.txt) and you add this

##############################################################

unoclock.name=Arduino/Genuino Uno w\ clock out!

unoclock.upload.tool=avrdude
unoclock.upload.protocol=arduino
unoclock.upload.maximum_size=32256
unoclock.upload.maximum_data_size=2048
unoclock.upload.speed=115200

unoclock.bootloader.tool=avrdude
unoclock.bootloader.low_fuses=0xBF
unoclock.bootloader.high_fuses=0xDE
unoclock.bootloader.extended_fuses=0xFD
unoclock.bootloader.unlock_bits=0x3F
unoclock.bootloader.lock_bits=0x0F
unoclock.bootloader.file=optiboot/optiboot_atmega328.hex

unoclock.build.mcu=atmega328p
unoclock.build.f_cpu=16000000L
unoclock.build.board=AVR_UNO
unoclock.build.core=arduino
unoclock.build.variant=standard

That should add a new board in the menu. And if you use that to burn the bootloader it will set the fuse to have a clock out. The rest is a copy of the normal Arduino so in normal use there is no difference in selecting this or the normal Uno. And when you want to disable the clock output, just burn the normal bootloader. That will restore the fuses.

You can probably detect the clock by "sniffing". Just put a scope probe very near but not touching the circuit.

Low fuse byte, bit 6 controls the system clock coming out:

unoclock.bootloader.low_fuses=0xBF

0xBF = 10111111, bit 6 low is what programs the fuse.

The lower 4 bits select the clock source, 1111 = low power crystal oscillator.

Mogaraghu:
I have a 30MHz oscilloscope ( in good working condition ) and would like to see the 16MHz clock waveform on a bare bone Atmega 328P running normally ( at least its blinking the LED at the expected rate ). I am using a 16MHz crystal and two numbers of 22pF capacitors.

Tried to see the waveform ( unsuccessfully ) on one of the crystal pins. Which would be the best way ? Is it possible to route the clock to one of the digital pins ?

Thanks

You will only have a chance of seeing this with 10x selected on your 'scope probe (in general always
use 10x, not 1x, if you want to observe a high frequency or high impedance circuit).

You should be able to see something, try both crystal pins as one is lower impedance than the other.

If you don't have a 10x probe, get one!

It won't be too ugly since he can only see the fundamental. Should look like a nice sine wave.