System - Fuse bits

  1. What are fuse bits?

    Fuse bits are a few bits stored in some special flash memory area. They are used to configure the how the chip will behave when powering on. (e.g. initilize system register to different value.) It is also said to be hardware set compared to software set by changing registers. For example, it can determine whether the chip has a bootloader, what speed (clock source) and voltage it is going to run at. Moreover, the status of the Fuse bits is not affected by Chip Erase.

    Terms

    • programmed: when saying a bit is programmed, it is equvilent to claim a bit is set. But it is written to 0 to be set.
    • unprogrammed: unset by written to 1.
  2. Fuse bits in Atmega328/p

    The device has three Fuse bytes. Extended fuse bytes (contains 3 fuse bits), fuse high bytes (contains 8 fuse bits), and fuse low byte (contains 8 fuse bits).

    Extended Fuse byte

    Extended fuse bits are used to configure the BOD circuit (a internal circuit that guarantees a enough time-out delay for stable Vcc). Moreover, BOD would reset the MCU if the Vcc is below the trigger voltage. There are three reference voltage levels for triggering the device. The low three bits in the extended fuse byte are defined and used to specify the trigger voltage level. Atmega328p's trigger voltage efuse[2:0] = 111 (BOD disabled), 110 (1.8V), 101 (2.7V), 100 (4.3V), others (reserved)

    No.NameMeaningDefault value
    2BODLEVEL21 (unprogrammed/unset)
    1BODLEVEL11
    0BODLEVEL0Brown-out Detector trigger levels set the BOD reference voltage.1

    High Fuse byte

    The high fuse byte enables/disables of the external reset, debugWIRE, serial program downloading, watchdog timer, and controls the behavior of EEPROM, the location of reset vector and the size of boot section.

    No.NameMeaningDefault value
    7RSTDISBLexternal reset disable1 (unprogrammed/unset)
    6DWENdebugWIRE enable1
    5SPIENEnable serial program and data downloading0 (programmed/set)
    4WDTONWatchdog timer is always on and works in reset mode1
    0BOOTRST = 1 (unprogrammed) the reset vector is at the begining of the application code, otherwise at the beginning of boot section.1 (arduino = 0)

    Low Fuse byte

    Low fuse byte contains 8 fuse bits. They are primarily used to configure the system clock, such as clock source, start-up time, and divided by 8.

    No.NameMeaningDefault value
    7CKDIV8Divide the clock source frequency by 80 (programmed/set)
    6CKOUTOutput the clock signal in the CLKO (PB0 pin)1 (unprogrammed/unset)
    5SUT11
    4SUT0SUT1 and SUT0 set the minimum #cycles required for a stable clock (default is the max start-up time for default clock source)0
    3CKSEL30
    2CKSEL20
    1CKSEL11
    0CKSEL0CKSELn select the clock source (default 0010 internal 8MHz RC)0

    The CKDIV8 bit's principle is to modify the Clock Prescaler Register (CLKPR) to divided the frequency by 8. In other words, if the CKDIV8 is programmed, then the initial value of CLKPR is 0x03.

  3. How to set fuse bits?

    Attention

    1. Cannot directly modify the fuse bit via arduino bootloader. A ISP programmer has to be used.
    2. When using an Arduino as ISP, a 10uF cap is needed to connect GND and RST.

    Read arduino fuse bit

    Resource: two Arduino Nano, one 10 uF cap

    1. Upload the Arduino ISP to Arduino Nano A.
    2. 10uF cap connects Arduino Nano A's GND and RST.
    3. Connection:
      Master/Arduino Nano Programmer ASlave/Arduino Nano B
      SCK (PB5, d13)SCK (PB5, d13)
      MISO (PB4, d12)MISO (PB4, d12)
      MOSI (PB3, d11)MOSI (PB3, d11)
      ~SS (PB2, d10)reset (RST)
      VccVcc
      GNDGND
    4. Arduino IDE burns bootloader to Arduino Nano B.
    5. Run

      avrdude -p m328p -c stk500v1 -b 19200 -P /dev/ttyUSB0 -v #v stands for verbose

    Result E: 0xFD, H:0xDA, L:0xFF