2
\$\begingroup\$

I have designed a custom board using an ATMega2560. The board works fine when configured to use the internal oscillator. The board stops working when I configure it to use the the external 16MHz crystal oscillator. When I place an o-scope probe at R4, the oscillator measures ~680Hz. What am I doing wrong? I even tried re-soldering the clock chip.

Here is the clock chip:

enter image description here

enter image description here

enter image description here

enter image description here

\$\endgroup\$
  • 1
    \$\begingroup\$ What is the function of R3? The ATMega2560 datasheet suggests no resistor is required, and this value will damp the crystal severly. Try removing R3. Also, R4 seems to serve no purpose - the value shown is too low to have any effect. \$\endgroup\$ – henros Apr 8 '18 at 8:42
  • 1
    \$\begingroup\$ Measure on the oscillator OUTPUT (which is buffered, low impedance, and better able to drive the load of a scope probe). Measuring on the high impedance input can kill the oscillation, which is probably what you're seeing. BUT ALSO bear in mind : digital oscilloscopes tell lies ... if yours is sampling at 16MHz + 680Hz on this timebase range, what you'll see is ... 680Hz. \$\endgroup\$ – Brian Drummond Apr 8 '18 at 10:06
  • 1
    \$\begingroup\$ @henros Your comment to remove resistors R3 and R4 was correct. Add it as an answer and I will accept it. \$\endgroup\$ – user8908459 Apr 8 '18 at 17:04
3
\$\begingroup\$

If the XTAL2 pin is an output (as indictaed on your schematic) then R4 needs to be in series with this pin and not XTAL1 (appears to be an input on your schematic). Without a proper value of R4 in the right place you may never get oscillations to occur. See my answers here and here explaining the various components surronding a crystal that make it oscillate.

\$\endgroup\$
  • \$\begingroup\$ Quote from the datasheet: "Pins XTAL1 and XTAL2 are input and output, respectively". And ATmega does not need any additional resistor to work properly. Page 11 mouser.com/ds/2/36/doc2521-41636.pdf \$\endgroup\$ – G36 Apr 8 '18 at 9:34
  • \$\begingroup\$ @G36 that document shows pins 36 and 37 as the xtal connections so it might be that the OP is even more confused than first thought. Of cource there could be a variant that uses 33 and 34 but he could still have got them wrong. \$\endgroup\$ – Andy aka Apr 8 '18 at 9:44
  • \$\begingroup\$ For ATmega2560 XTAL1 is pin 34 and XTAL2 is pin 33. But as I said I never used any additional resistors with AVR. And external crystal work jus fine. \$\endgroup\$ – G36 Apr 8 '18 at 9:54
  • \$\begingroup\$ @Andyaka I have removed the resistors per the datasheet and bridged the connection across R4. The output still looks the same. \$\endgroup\$ – user8908459 Apr 8 '18 at 16:39
  • 1
    \$\begingroup\$ Good man - maybe you should consider leaving an answer to that effect explaining where things went wrong and how you solved it. Doesn't have to be long and someone, somewhere might just appreciate it. \$\endgroup\$ – Andy aka Apr 8 '18 at 17:59
0
\$\begingroup\$

As posted in other responses, I had to remove R3 and R4, but I also had to burn different fuse setting using the following avrdude command

avrdude -c usbasp -p atmega2560 -C ../etc/avrdude.conf -U lfuse:w:0xff:m -U hfuse:w:0x99:m -U efuse:w:0xff:m

Fuse setting can be calculated here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.