View Full Version : Using External Crystal for AVR MCU

09-30-2008, 01:37 AM
Hi all,
I tried to search the forums here but i could not get an appropriate answer to my queries so im posting a new topic.
Sorry if it's been repeated.

I'm new to AVR programming.
I had AtMega8-16PU.
I flashed some hex file to it successfully without touching the fuse bits.
I wanted to use 12Mhz ext crystal as clock source.
I change the fuse bits setting to:


Problem: My mcu has stopped responding. The programmer doesnt recognize it.

Critical Info:
1. I used a not so standard Parallel Port Programmer AtProg built using the schematics here..http://www.speedy-bl.com/avr-prog-e.htm
2. The programmer uses serial downloading commands for setting fuse bits
So i gave commands:
;for LFUSE
AC A0 00 9F
;for HFUSE
AC A8 00 C9

refer to datasheet ATMega8.


Some idea i gathered:
1. When fuse bits are set for using the ext crystal the mcu now depends on ext crystal for its working. so every time it is to be used we need to provide the ext crystal. even we have to program it. the programmer will not detect it unless the ext crystal is provided coz the mcu wont work without it.

So i put the same 12Mhz crystal in the board for which i intended to use the mcu. but still the programmer doesnt detect it i have no clue if its working or not.

2. I learnt that we can reset the fuse bits of the mcu using High Voltage Parallel Programming.
This option is available in STK500 kit but unfortunately i have no access to it.
One schematics i found on net which could do HVPP is here:http://elm-chan.org/works/avrx/report_e.html
But i'm not sure if it will work at all.
And moreover i'm looking for a alternate easy solution if there is any.


Some very basic query:
IF i use PonyProg2000 and STK200/300 dongle to program the mcu and then try to change the fuse bits settings for using ext crystal.. will PonyProg also not detect the mcu??

I guess this is a very basic query and a problem faced by almost all newbie i assume.

Plz provide any information you have regrading this.. all replies appreciated. this will help any like newbie learn without screwing up the mcu.

09-30-2008, 04:50 AM
Dont mess with the fuses if you dont know what u doing :twisted: .

Anyhow u have set it to ext low frequency crystal. Not what u wanted to set it to.

It should have been this , i think


If you cant find a low freq crystal , welcome to the bricked club :) . HV programmer is gonna be more exp than replacing a mega 8.

09-30-2008, 11:30 AM
i am asking this for third time..... is your uC atmega8 or atmega8L. because most probably it would be megaL. its more popular nowadays because of low power and cost. if so maximum allowed frequency is 8MHz.

and for fuse bits . they are a mess.
according to me the settings for your case should be (making changes only to clock selection needs and keeping other things at default)
use two 27pF or less capacitors.

why are you enabling the brown out detector??
there is a twist in SUT settings. with internal oscillator SUT1,0=10 means low frequency and with external crystal SUT1,0=10 means high frequency.

09-30-2008, 02:47 PM
i very clearly mentioned my mcu is ATMega8-16PU
This 16PU or sometimes 16PI means this mcu can work at max 16MHz..
Hope im clear.
As for the rest Actually i was programming this AtMega8 for USBasp firmware and the README.txt with it very said i needed to change the fusebit settings for ext crystal..
And wen i read it's makefile it was clearly mentioned the same fuse settings as i have done:


# Fuse atmega8 high byte HFUSE:
# 0xc9 = 1 1 0 0 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000)
# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
# | | | | | +-------- BOOTSZ1
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase)
# | | | +-------------- CKOPT (full output swing)
# | | +---------------- SPIEN (allow serial programming)
# | +------------------ WDTON (WDT not always on)
# +-------------------- RSTDISBL (reset pin is enabled)
# Fuse atmega8 low byte LFUSE:
# 0x9f = 1 0 0 1 1 1 1 1
# ^ ^ \ / \--+--/
# | | | +------- CKSEL 3..0 (external >8M crystal)
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
# | +------------------ BODEN (BrownOut Detector enabled)
# +-------------------- BODLEVEL (2.7V)
And moreover i read the datasheet i found the CKSEL CKOPT SUT were okay.. rest i did not bother about.
So i have no idea of BrownOUt detector things.. i'l read about it and then post.

don't get angry.. after all i lost a mcu not u :wink:
And u won't learn until u loose fear of failure.
It's Okay it was my first attempt after all

And i cant understand how do u think changing the HFUSE(that too BOOTRST to 0) could possibly affect the ext clock settings????
Except that there's no difference between wat u mentioned and wat i have done.
And how do u say i set it to low frequency crystal..??
I referred the data sheet and it clearly says..

Device Clocking Option CKSEL3..0

External Crystal/Ceramic Resonator 1111 - 1010
External Low-frequency Crystal 1001
External RC Oscillator 1000 - 0101
Calibrated Internal RC Oscillator 0100 - 0001
External Clock 0000


CKOPT CKSEL3..1 FrequencyRange(MHz)
1 101(1) 0.4 - 0.9
1 110 0.9 - 3.0
1 111 3.0 - 8.0
0 101, 110, 111 1.0 ≤

What's done is done
Plz tell me how to set the fuses for ext crystal.
plz help out

09-30-2008, 03:09 PM
im just teasing ;) ... not angry

Anyway here is a calculator for you


09-30-2008, 03:51 PM
thanks a great link...
but did u read this thing given below???

"Unreviewed original XML backend database from Atmel. Possibly buggy!"

ha ha ha :lol:

09-30-2008, 03:55 PM
I know that , Most things have conditions attached :) .

09-30-2008, 06:01 PM
really great link......

ah, i didnt knew about that 16PU thing..... thanks for sharing.

well, the calculator show that all three of us are right in selecting clock, the only difference is in other settings and i think they wont affect the working here.

09-30-2008, 07:02 PM
okay... we agree at something atleast.
So where's the problem??
If fuse settings are okay.. y doesnt the mcu work??

can u ppl share ur experiences of using ext crystal??
how did u do it?? wat programmer did u use to set fuse?? plz help out.

09-30-2008, 09:36 PM
here in my city only 'L' version is available (and i also prefer them because of low cost). so never used more than 8MHZ crystal. i used a 4MHz crystal just to try and i faced no problem. i cant say which programmer it was. actually i used avrdude and changed the config file according to me. so that was not some standard programmer.

10-01-2008, 11:45 AM
have you tried decreasing the speed of atprog?

10-02-2008, 01:57 AM
yes.. i tried that.. nothing works..
now im building a new ponyprog serial progrmmer. i'l try with that.
and well i gotta know this the circuit that is given for At-Prog is nothing but a simple bsd programmer.

10-02-2008, 08:14 PM
Use HandyProg for programming, its user interface is simple for fuse bit settings.

10-02-2008, 08:53 PM
I thought of using PnoyProg... infact im done with the hardware interface of PonyPorg.( but the thing keep saying "Device Missing or Unknown Device(-24) I'l have to fix that.)

10-02-2008, 08:59 PM
Anyways C'on ppl u all must have used ext crystal with one of the avr mcus.. plz tell me wat programmer did u use and did it work..? after setting the fuse bits mine's stopped working did the same happen to u..??

10-02-2008, 11:45 PM
Ive used pony prog a lot ( my fav AVR ISP programmer ) ... and i always use external crystals.

Just set the fuses right :) ... works just fine.

10-06-2008, 07:40 PM

I am giving a tested fuse setting. I have used them on more than 30 ATmega8 MCUs


@ashish_agarwal123456 It is not like ATmega8L-8PU won't work with a 12MHz crystal I have successfully overclocked ATmega8-8PU upto 16MHz !!!

It u provide 5V to the "L" they will happily work over 8MHz

10-06-2008, 09:01 PM
hey!!! i didn't knew that.... will give it a try...

10-22-2008, 03:38 AM
thank u all for showing such enthusiasm and helping me out.

Problem Solved!

I used some programmer in which i had to give commands for setting the fuses and i dont know how but i made mistakes and messed up with the lock bits and so it was not responding.

In fact vikas, ashish,... u all were right. its about getting the fuses right!!

Lesson: for everyone who starts out with Atmega fuse settings i would suggest to use some good programmer with GUI so that u never mess up.
Use Ponyprog or AVRstudio.

I use avr studio and now i never mess it up wen setting fuses.. it jus works fine each time.