[digg=http://digg.com/programming/AVR_Fuse_Bits_for_clock_selection]
VIMP NOTE:
fuse bit = 0 => fuse bit is PROGRAMMED
fuse bit = 1 => fuse bit is UN-PROGRAMMED
Fuse bits configuration is required when one has to change default factory setting of clock (internal/external) to desired setting. This is most important thing and setting fuse bits incorrectly may render microcontroller useless. Let us see which different fuse bits are available for different AVRs and their uses. We will use PonyProg2000 for configuring fuse bits. PLEASE NOTE that discussion on this page is limited only for configuring AVR fuse bits for clock source selection.
There are different clock sources available for AVR. They are : internal RC oscillator, external crystal/ceramic resonator, external clock. Mostly we need either internal RC oscillator or external crystal hence we will only concentrate on that. Once you understand the process u can configure for other options with the help of datasheet.
Internal RC oscillator :
Many AVRs (like ATmega8, ATmega16, ATmega32) have internal RC oscillator. It is calibrated for 1,2,4 or 8 MHz. It has +-3% accuracy. Frequency of oscillator gets affected by VCC and temperature. If you are not performing any time critical operations in your system, then this is best option to go with. Following table shows how to set CKSEL fuses for different frequencies. This table can be found in corresponding AVRs datasheet. CKOPT fuse should always be unprogrammed while using this option.
CKOPT
|
CKSEL3…0
|
Freq
|
1
|
0001*
|
1.0MHz
|
1
|
0010
|
2.0MHz
|
1
|
0011
|
4.0MHz
|
1
|
0100
|
8.0MHz
|
*If your AVR has internal RC oscillator then, device is shipped with this option.
Crystal oscillator:
Crystal oscillator should be used when u need accurate frequency of operation. CKSEL3,2,1 fuses should be configured as follows for crystal oscillator. If you want to use crystal of frequency more than 8MHz then CKOPT should be programmed. NOTE : setting of CKOPT depends on speed grade of your AVR. However please note that CKSEL0 fuse along with SUT0,1 is used for startup time selection in this mode. Refer datasheet for more info.
For AVR with 8PI or 8PU (i.e. max frequency of operation is 8MHz)
CKOPT
|
CKSEL3..1
|
Freq (MHz)
|
Decoupling Capacitor
|
1
|
101*
|
0.4 – 0.9
|
–
|
1
|
110
|
0.9-3.0
|
33pf
|
1
|
111
|
3.0-8.0
|
33pf
|
0
|
101,110,111
|
1.0
|
33pf
|
For AVR with 16PI or 16PU (i.e. max frequency of operation is 16MHz)
CKOPT
|
CKSEL3..1
|
Freq (MHz)
|
Decoupling Capacitor
|
1
|
101*
|
0.4 – 0.9
|
–
|
1
|
110
|
0.9-3.0
|
33pf
|
1
|
111
|
3.0-8.0
|
33pf
|
0
|
101,110,111
|
1.0 – 16.0
|
upto 8MHz : 33pf
more than 8MHz : 27pf |
*This setting is only for ceramic resonators
You can get more information about crystal oscillator from datasheet.
I have put ready-made snap shots of fuse bit settings for different AVRs :
- ATmega16/32 – external xtal upto 16MHz, full oscillator swing, slow rising power (65ms), JTAG disabled
#
Hi
can you help me about default values of clock sources in QFN or PIDP packages of atmega16?How can I recognise that?
#
They are same. Please check the datasheet pin diagram.
#
Thank you. useful.
#
#
Thanks for sharing. Sometimes I found fuse setting like this: Start-up time: xx CK + x ms , what is that mean? Thanks.
#
Good article and I appreciate that!
#
Thanks for sharing!
It’s impressive!
#
Are there any C codes showing how to use CKSEL fuses to swith to an external clock source?
thx
#
Fuse bits are not configured in the “C” code. They don’t have any relation with C code. These bits have to be programmed manually.
#
ok thanks…but can you tell my why i cannot connect one pin of the TX to ground directly ? bcoz i have tested the TX with a function generator ,n it works fine. wouldn’t LOW of the uC be equal to ground ?
#
Hello…i’m new to avr’s,and have used only 8051 before. i’m doing a project,in which i shall be operating the atmega-32 uc such that the OC2/D7 pin is the output. The OC2 o/p will be used to drive an ultrasonic transmitter,and my tests reveal that the ultrasonic transmitter needs atleast 3V for sufficient range.
Can you tell me what the output voltage of the OC2 pin is ? also,if it is less than 2 V,can u suggest some way of pulling it up ? Can i use a opamp? OC2 frequency will be 40 Khz.
#
>>piscianemperor
HIGH voltage level on the all I/O Pins of uC is always close to VCC. If you give 5V as VCC to ur uC output high voltage will be close to 5V. So you can connect ultrasonic TX to the uC directly. However you cannot connect one pin of TX to uC and other pin to GND. For proper operation and increased range you will have to give complementary signals to each pin of TX. You generate such complementary square wave signals using CTC mode of the timers.