ATmega8 Fuses and AVRDUDE

An ATmega8 on a bredaboard is wired up to an USBASP so that AVRDUDE can do its job easy.
The chip is an ATmega8A-PU working with an internal clock (no external quartz), using AVRDUDE ver.5.11-PATCH#7610.

Since all I wanted was to read those fuses I came to this command line which does it all in a verbose manner:

avrdude -c usbasp -p m8 -U lfuse:r:lfuse.hex:i -v

result being:

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"

         Using Port                    : lpt1
         Using Programmer              : usbasp
         AVR Part                      : ATMEGA8
         Chip Erase delay              : 10000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom         4    20   128    0 no        512    4      0  9000  9000 0xff 0xff
           flash         33    10    64    0 yes      8192   64    128  4500  4500 0xff 0x00
           lfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  2000  2000 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e9307
avrdude: safemode: lfuse reads as E1
avrdude: safemode: hfuse reads as D9
avrdude: reading lfuse memory:

Reading | ################################################## | 100% 0.02s

avrdude: writing output file "lfuse.hex"

avrdude: safemode: lfuse reads as E1
avrdude: safemode: hfuse reads as D9
avrdude: safemode: Fuses OK

avrdude done. Thank you.

and it also created a lfuse.hex file that contains:

:01000000E11E
:00000001FF

From page: http://www.frank-zhao.com/fusecalc/fusecalc.php?chip=atmega8 I get that this chip has SUT1 disabled (Start-up time is now 6CK + 64MS) and WTDON disabled (Watchdog timer is now not always ON). I don’t know if it came that way from the vendor or I did flash new fuses by uploading some kind of bootloader with Arduino IDE in the past. I really can’t say. Anyway, it currently works fine :-)

A quick note on the clock source and frequency.
I use the ATmega8 with its internal oscillator. It may run at 1MHz or at 8MHz. All it takes to set it up is burning the correct fuse bits.
The chip I’m using now has lfuse=0xE1. Hexadecimal 0xE1 value is equal to binary 11100001. Those bits are the lfuse bits: BODLEVEL, BODEN, SUT1, SUT0, CKSEL3, CKSEL2, CKSEL1, CKSEL0. Atmel’s ATmega8 datasheet chapter 8.2 makes it all clear. First of all it says: for all fuses “1″ means unprogrammed, “0″ means programmed. So CKSEL01=1 means CKSEL0 is unprogrammed (not the contrary), CKSEL1=0 is programmed, SUT1, SUT0 are 1,0 and so on.
Anyway, the current combination is CKSEL=0001 (all four of them together make it CKSEL) and SUT=10; that means “Calibrated Internal Oscillator” set at 1MHz and Slowly Rising Power.
Actually there’s also the combination 0100 that corresponds to the same clock source, the difference is the frequency. Setting CKSEL at 0100 makes it run at 8MHz instead. That’s not this case, but it’s easy to set that in the chip with the command line:

avrdude -c usbasp -p m8 -U lfuse:w:0xE4:m  -u
Posted in ATmega