Bits de fusível AVR ATmega16/32

AVR ATmega16/32 Fuse Bits

Summary

Updating with the age of technology, the new microcontrollers are coming with many peripherals and built-in features. These peripherals and integrated features not only reduce the cost of additional circuitry to be used with the controller, but also make it easier to interface additional devices (such as modems, etc.) directly with the microcontroller.

The new generations of microcontrollers are capable of working with both internal and external clock options. But then the question arises that how can we make them work on the desired clock option? How to disable/enable a certain peripheral? As a beginner, when you get a new chip ( ATmega16 /32) you may complain that 'CHIP PORC is not working!' or 'when reset pin and 6th pin of PORTC (on ATmega8) are common how should I select/distinguish them?'. These issues may seem bitter when you try to ignore them and move on, but all these problems can be resolved by properly setting the FUSES of your device.

There are few parameters on the chip which are used to configure it before it can be used in outdoor environment. These parameters are defined using Fuse Bits. In other words, the fuse bit determines the behavior of the chip, whether it has a boot loader, what speed and voltage it operates at, the watchdog timer conditions, etc. The main advantage of fuse bits is that the microcontroller can be configured as needed.
Once the fuse bits are set to a specific configuration, the controller can be used repeatedly (the program can be written repeatedly). You don't need to set the fuse bits every time you are using the controller until the time you want to use it in the same configuration. Fuses only need to be changed if you want to change the initial configuration of the controller. Fuse bits are very confusing for beginners. This tutorial will explore the fuse bits and also provides a clear understanding of which fuses you need to set for your device.

Description

Description
Before setting your device's fuses, you need to have an in-depth understanding of the fuses, when exactly and how you would set them, and what are the factors that can affect the functioning of the device. It is important to note that the fuse bit settings are not affected by the chip erase operation. They are configured separately using an external programmer.
Another very important aspect to note is that the desired fuse bits must be programmed before setting the device lock bits. You must be very careful when writing device fuses. Suppose if you are using an IPS programmer/writer to program your controller and by chance you have disabled (unprogrammed) the SPIEN bit, then the chip cannot be programmed anymore. The SPIEN bit can again be enabled (programmed) using a parallel recorder. If the bit is read as logic 0, it means that the bit is programmed or else it is called an unprogrammed bit.
The AVR microcontroller (ATmega16) consists of sixteen fuse bits which are classified as low fuse and high fuse. These fuse bits can be configured to select microcontroller clock options or to control some built-in peripherals like JTAG, SPI etc.
A new or virgin microcontroller has a default fuse byte value that is equal to 0x99E1 in hexadecimal. To understand the meaning of this default value, each fuse bit must be understood.
High fuse bits:
Fuse
OCDEN
JTAGEN
SPY
CKOPT
EESAVE
BOTASZ1
BOTASZ0
BOOTRST
Little No.
Part 7
Part 6
Part 5
Part 4
Part 3
Part 2
Part 1
Bit 0
Standard
values
1
0
0
1
1
0
0
1
Low fuse bits:
Fuse
BODY LEVEL
BODEN
SUT1
SUT0
CKSEL3
CKSEL2
CKSEL1
CKSEL0
Little No.
Part 7
Part 6
Part 5
Part 4
Part 3
Part 2
Part 1
Bit 0
Default values
1
1
1
0
0
0
0
1

The individual fuse tip is explained in the next section.

Fuses

CKSEL (3:0) (clock selection)
These fuse bits are used to select different clock source options for the microcontroller. The table below shows the different device clock sources and their corresponding fuse bits.
Device clock option
CKSEL(3:0)
External crystal/ceramic resonator
1111 – 1010
Low Frequency External Crystal
1001
External RC Oscillator
1000 – 0101
Calibrated internal RC oscillator
0100 – 0001
External Clock
0000

The default clock setting for the new controller is CKSEL = 0001 (1 MHz internal RC oscillator). Generally, the external crystal is used as a clock option (so the fuse bit is set between the range 1111-1010).

CKOPT (clock option)
There are two oscillation modes in the ATmega16 microcontroller; the CKOPT bit selects one of these modes. If the CKOPT bit is set (0), the oscillator generates full rail-to-rail output oscillation. This mode has a wide frequency range. If CKOPT is not programmed (1), the oscillation will have lower output oscillation (this mode is frequency limited).
The Atmega16 can be operated at a maximum clock frequency of 16 MHz (16PU or 16PI), so CKOPT is programmed. The CKOPT bit is combined with CKSEL bits (3:1) to select the operating frequency and its mode. Table 2 shows the CKSEL(3:1) and CKOPT bit combination used to select the crystal frequency for ATmega16. The table below also recommends the ranges of capacitors connected to the crystal.
CKOP
CKSEL(3:1)
Frequency range (MHz
Recommended range for capacitors (pF)
1
101*
0.4 – 0.9
1
110
0.9 – 3.0
12 – 22
1
111
3.0 – 8.0
12 – 22
0
101, 110, 111
1.0 -16.0
12 – 22
* This mode is only used for ceramic resonator.
For CKOPT=0, the CKSEL (3:1) bits are selected as follows:
Imagem mostrando os Fusíveis selecionados
Fig. 1: Image showing selected fuse bits
For external crystal frequency of 12 MHz, CKSEL (3:1) is set to 111.

Fuse bits, continued

SUT (1:0) (start time)
This bit is used to set the ATmega16 boot time. The combination of the SUT (1:0) and CKSEL0 bits is used to select the controller initialization time. The table below shows the bit combinations for selecting the boot time.
CKSEL0
SUT(1:0)
No. of startup clocks
Additional restart delay
Recommended use
0
00
258 CK
4.1ms
Ceramic resonator, fast boost power
0
01
258 CK
65ms
Ceramic resonator, slowly increasing power
0
10
1KK
Ceramic resonator, BOD enabled
0
11
1KK
4.1ms
Ceramic resonator, fast boost power
1
00
1KK
65ms
Ceramic resonator, slowly increasing power
1
01
16KK
Crystal oscillator, BOD enabled
1
10
16KK
4.1ms
Crystal oscillator, fast
growing power
1
11
16KK
65ms
Crystal oscillator, slowly increasing power

BODEN (darkening detection activation)

ATmega16 has a brown-out detection and continuously monitors the Vcc level with fixed trigger level. This fuse is used to activate/deactivate the power outage detection unit. To enable the BOD unit, the BODEN bit is set (0).

BODLEVEL (dimming detection level)

This fuse tip is used to set the trip level of the BOD unit. The trigger voltage is set to 2.7 volts if the BODLEVEL bit is not set (1). If this fuse bit is programmed (0), the trip level will be set to 4.0 volts.
BOOTRST (BootLoader reset)
BootLoader is a small program written in a specific area of ​​flash memory. This program runs at controller initialization time. If the BOOTRST bit is set (0), the device will jump to the first block of the address bootloader.
BOTASZ (1:0)
This fuse is used to set the bootloader size. The default value of these bits is '00', which sets the initialization size to 1024 words. This size is allocated in flash memory. The bootloader always resides at the bottom of the flash.
Imagem mostrando o posicionamento do Bootloader com o programa principal

Figure 2: Image showing the positioning of the Bootloader with the main program

EESAVE (Save EEPROM)
This bit is used to preserve the contents of the EEPROM during chip erasure. If the fuse is programmed (0), the EEPROM preserves its contents, otherwise it will not be preserved during chip erasure.
SPIEN (SPI Serial Programming Enable)
If this bit is set (0), the controller's SPI serial programming is enabled. To disable serial programming, this bit is left unprogrammed (1).
JTAGEN (enable JTAG)
There is a JTAG unit built into the ATmega16, which is pre-enabled in the blank microcontroller. To disable JTAG, the JTAGEN bit must not be programmed (1). (Refer How to disable JTAG )
OCDEN (on-chip debug enablement)
On-chip debugging is used to run the program step by step on the hardware to study the internal signal that provides the information about the state of the processor. This bit is used to enable/disable on-chip debugging. If this bit is set (0), then on-chip debugging is enabled.
There are a few more bits that are not present in the ATmega16, but are important when using other AVR series ICs like the ATmega8. The RSTDISBL bit is very important (especially in the case of the ATmega8). When programming this bit, the reset bit is converted into a general I/O pin. It should be noted that when using the SPI programmer, this bit should never be programmed. Programming this bit would disable SPI programming, since all SPI programmers use the RESET pin to program the microcontroller (AVR).

Configuring a new microcontroller

Configuring a new microcontroller
A virgin microcontroller controller is configured with internal 1 MHz RC oscillator with longer startup and JTAG pre-enabled. Therefore, the fuse bytes are as follows: Imagem mostrando o status dos Fuse Bits para microcontrolador virgem

Figure 3: Image showing Fuse Bits status for blank microcontroller

To configure the microcontroller for external high frequency with longer startup and JTAG disabled, the fuse settings are changed as follows.
Imagem mostrando o status dos Fuse Bits para alta frequência externa com inicialização mais longa e JTAG desabilitado

Figure 4: Image showing fuse status for external high frequency with longer startup and JTAG disabled

Refer to JTAG disabled on AVR learn fuse byte read/write operation using AVRDUDE.

Related Content

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.