I am experimenting with the "Clock output on PORTB0; [CKOUT=0]" fuse option on an ATMEGA328P-AU hoping to use the output to "revive" bricked ATMEGA MCUs that have been set to wrong clock sources. So I took out this one "Arduino Nano" and went ahead to set it to output clock (LF=BF). Hooked it up to a scope and got the waveform. It's sine-looking with the right 16MHz frequency. But the amplitude is pretty high, at over 10V peak-to-peak and goes between -3V and +7.5V. My scope CH1 is set to default X1 so this is real. I supplied 5V across "5V" and "GND" of the nano and have shared GND between my PSU/Arduino and my scope. Any advice? Thanks.
liuzengqiang:
...hoping to use the output to "revive" bricked ATMEGA MCUs that have been set to wrong clock sources...
Just so you know... It's fairly easy to accomplish that by configuring a timer (CTC, scaler = 1).
Adafruit, Nick Gammon, and I all have versions of Arduino ISP that use a timer for such purposes.
Thanks Coding Badly. I'll do that as my next attempt. I'm still interested in understanding the CKOUT pin though. My analog signal generator is able to output up to 10MHz. Maybe I'll just send that to the bricked Arduino (it's effectively underclocking, running at 10MHz and 5V, right?). Do you know if the input side ()XTAL1) of ATMEGA328P is accepting 0-5V square wave or does it have to be sine?
The clock speed is not terribly important. It does have to be 6 times the SPI clock. For example, if you are using the typical 125 kHz to program, the target's clock has to be >= 750 kHz. In this example a clock of 10 MHz for the target should work well. (Ugh. That may be 3 times. In any case, 6 times will definitely work.)
I believe anything that covers the hysteresis will work on XTAL1. Sine, square, triangle, cosine ... should all be good as long as the minimum voltage is low enough and the maximum voltage is high enough. (Though there may be some timing limits regarding how much difference there is between the low period and the high period.)
Regarding Clock Output (CLKO) ... that does seem strange. I have used CLKO to drive a TLC5940. I highly doubt that chip would tolerate a 10 V swing. Other than that I cannot offer anything helpful.
BTW
I am surprised the waveform looks like a sine wave.
I suspect it is your scope response that is making look so good.
I have done similar here with a scope with 400Mhz 3db point and it appears like a dirty rounded cornered 5v square wave.
Must be careful with limited bandwidth equipment.
Similar to this but at 16Mhz:
.
Xtal1 works with a squarewave input.
Your claim of a 10v swing doesn't make sense; there's nowhere for it to get the +7v or the -3v from. It's supposed to be a swing from 0v to 5v (or whatever the opperating voltage of the chip is), and it's supposed to be a square wave, not a sine wave....
I'll try a second Arduino Nano to compare the waveforms. The scope I used today is a 60MHz one. I'll use a 200MHz scope tomorrow. That's the fastest I have and there is no USB and the screen is literally shot (by laser)
I think it needs to look like a sine wave to have any chance of being accurate (but that is just my hunch). This is what my 1284p looks like with Full Swing Oscillator mode.
Thanks Ron. Was this the CKOUT result or the timer output? I tested a second nano and the output is similar to the first one, even higher voltage around 16V Pk-Pk on my 200MHz scope. The waveform looks like a sine wave 10V to -5V. Strange.
My image was the output from the oscillator (XTAL2). I don't have the fuse for CKOUT set (that would be the PB1 pin on 1284p), so that waveform larryd has shown is making sense now. I was baffled by that waveform but had not looked into the CKOUT function until now.
Update: Perhaps the test probe is resonating. I think they can do some strange things at a magic frequency when not tuned properly. My scope has a square wave output that I can tune the probe with, but I only do that when I move the probe to a different scope.
I'm pretty sure that the "Clock output on PORTB0" should give you a 5V square wave. It shouldn't be a raw oscillator signal; it should be the system clock buffered by "typical" GPIO Output port buffering.
It must be some sort of measurement error...
How about this? I'll try and create a 10MHz square wave on my analog function generator and see if there is any resonance? I'm going to just use the function generator to feed 1MHz square wave to the bricked MCU instead of the CLKOUT for now. Maybe if I have access to better probes and scopes I'll try again.
I got a nice 5V square wave on a m168 on a BoardUino (easiest thing to reset fuses on.)
(Well, not THAT nice; some bounce, and some noticeable rise/fall times, but much cleaner that the waveform on the actual oscillator pins...)
(60MHz Tek TDS210..)
liuzengqiang:
. . . the amplitude is pretty high, at over 10V peak-to-peak and goes between -3V and +7.5V. My scope CH1 is set to default X1 so this is real. I supplied 5V across "5V" and "GND" of the nano and have shared GND between my PSU/Arduino and my scope. Any advice?
A terminating resistor, preferably at the at the oscilloscope probe end if there are significant wire lengths? A scope or probes with bandwidth less than the third harmonic (48 MHz) will give you a sine wave looking signal by virtue of suppressing the harmonics, but it shouldn't be that big.
OK I did some more tests, this round using proper probes, not just mini-grabbers. Here is a screen grab from my 60MHz scope. CH1 on top is about 4V with Tektronix P2220 voltage probe. CH2 on bottom is from a pair of mini grabbers (no terminating resistors. It still shows very large voltage and a phase shift. I got to read about these probes.
The story continues. I fed this signal to my board, doing some acrobatics with a wire from a Nano to send the clock signal, pogo pins for ICSP on the target board, and the other hand using a terminal program to interact with Nick's hex uploader.
I was able to change the fuse values but the board would no be recognized once I remove the external clock. I reflowed the XTAL pins and the oscillator pads I suspected were not well done. Nothing. Then I removed the oscillator and resoldered it on. Still nothing. I decided then to replace the oscillator, that's when this following happened:
The whole tiny assembly came apart. So I replaced it with a good one and everything was peachy. This is the second time crystal/oscillator caused some problems on my boards. I now only buy HC-49 type crystals from digikey or mouser.
Will someone recommend a part number for these little 16MHz 3-pin oscillators that have worked well on your design? This has the same footprint as all recent arduino boards. Much appreciated.
Will someone recommend a part number for these little 16MHz 3-pin oscillators that have worked well
- I don't think the average definition of "worked well" includes "ability to be de- and re-soldered on a board." These are tiny, cheap, resonators designed to be machine-assembled, once.
- These are crystals or resonators, not "oscillators." To be an oscillator, it would have to contain active components and draw power. Three-pin resonators contain built-in load capacitors, but they're still fully passive.
- Yeah, I wish the Uno had retained the PCB footprint for the crystal as well as the resonator
westfw,
Right, they are not oscillators, resonators instead. I found this one maybe it is good enough:
By the way, the part I found on mouser has 15pF load capacitance. According to 1284P's spec sheet 9.2.3 Clock source connections,
C1 and C2 should always be equal for both crystals and resonators. The optimal value of the capacitors
depends on the crystal or resonator in use, the amount of stray capacitance, and the electromagnetic noise of
the environment. For ceramic resonators, the capacitor values given by the manufacturer should be used.
So according to 9.4 Full swing crystal oscillator, recommended C1 and C2 value is 12-22pF, then choosing load capacitor value of 15pF should be good, right? This is the capacitance of the mouser part.
Another question: according to the spec sheet and this fuse calculator, I should use LF=C7 for full swing ceramic resonator with slowly rising power and to ensure freq. stability.
http://www.engbedded.com/fusecalc/
Instead I used LF=F7, which is the same option but for crystal and it works (to what reliability?). I wonder what difference it makes when you choose these options. Are there different oscillator settings for crystals and ceramics?
Bummer I am a little over the 1284P's spec sheet 9.2.3 Clock crystal recommendations, I have 27pF with a crystal that has a 20pF load capacitance. The crystal I'm using is rated for use with a 20pF load and I guess about 6.5pF is from stray. So that gives ( 6.5pF + (27pF*27pF)/(27pF +27pF) ) = 20pF.
Full swing crystal oscillator,
Note that many of more recent chips have deprecated or deleted the "full swing" oscillator (including some existing chips moved to new fabs, or something. See Atmel Removes Full-Swing Crystal Oscillator | Hackaday) So ... if you can get things to work with the "normal" oscillator, you should probably do so. (Although IIRC the 1284P has reset problems that using the full-swing oscillator was supposed to help alleviate. Sigh.)