Discussion ATmega328P Fuse settings
Revision as of 03:30, 23 March 2019 by U731219879 rc (talk | contribs) (Created page with "'''Warning:''' Programming incorrect fuse bits may lead to permanent damage of your micro-controller chip.<br> Before changing the fuses - Check Twice flash once! '''Fuses.''...")
Warning: Programming incorrect fuse bits may lead to permanent damage of your micro-controller chip.
Before changing the fuses - Check Twice flash once!
Fuses. Few rules for starters: Never change DWEN, SPIEN and RSTDSBL fuses. In fact they cannot be written when you are in ISP programming mode; Double check CKSEL fuses twice before writing. These cause most problems when wrong clock source is selected. Don’t touch lock bits. Unless you are producing commercial products and want to protect your software.
If unsure – read datasheet or ask questions.
1 MHz ATmega328P Default Fuse Settings avrdude -p m328p -c usbtiny -v -U lfuse:w:0x62:m -U hfuse:w:0xD9:m -U efuse:w:0xFF:m Low fuse = 0x62 (B01100010) High fuse = 0xD9 (B11011001) Extended fuse = 0xFF (B11111111)
8 MHz Internal clock avrdude -p m328p -c usbtiny -v -U lfuse:w:0xE2:m -U hfuse:w:0xD6:m -U efuse:w:0xFF:m 8 MHz crystal oscillator medium rising power with EEPROM preserve: avrdude -p m328p -c usbtiny -v -U lfuse:w:0xFE:m -U hfuse:w:0xD1:m -U efuse:w:0xFF:m 8 MHz Internal RC oscillator with prescaller off. avrdude -p m328p -c usbtiny -v -U lfuse:w:0xE2:m -U hfuse:w:0xD9:m -U efuse:w:0x07:m
16 MHz Default avrdude -p m328p -c usbtiny -v -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0xFF:m 16 MHz ceramic resonator fast start: avrdude -p m328p -c usbtiny -v -U lfuse:w:0xCE:m -U hfuse:w:0xD9:m -U efuse:w:0xFF:m 16 MHz crystal, slow start + CLKO clock: avrdude -p m328p -c usbtiny -v -U lfuse:w:0xF7:m -U hfuse:w:0xD9:m -U efuse:w:0xFF:m
Arduino Uno: 16 MHz Standard Arduino Uno settings. avrdude -p m328p -c usbtiny -v -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0x05:m = Arduino Uno Slow power starting, Bootloader enabled with boot size 128 words (optiboot). Typical brown out voltage selected at 2.7V. Low fuse = 0xFF (B11111111) High fuse = 0xDE (B11011110) Extended fuse = 0x05 (B00000101)
Fuse Calculators:
Engbedded Atmel AVR® Fuse Calculator
Eleccelerator.com/fusecalc/
Low Byte Fuse
File:LowFuseSetting.PNG Example set to 8 MHZ E2 1110|0010
These 8 bits are explained here: Set = 0 | Not Set = 1 Bit-7 : CKDIV8 : When set divides the clock speed by 8 1 (Not Set) Bit-6 : CKOUT : When set clock pulses on PB0 (Pin 14) 1 (Not Set) Bit-5 : SUT1 : Startup time delay 1 (Slow rising power option see data sheet section 9.6 table 9-12) Bit-4 : SUT0 : Startup time delay 0 (Slow rising power option see data sheet section 9.6 table 9-12) Bit-3 : CKSEL3 : Set the clock source 0 (4bits to set Internal Clock see data sheet Section 9.2 Table 9.1) Bit-2 : CKSEL2 : Set the clock source 0 (4bits to set Internal Clock see data sheet Section 9.2 Table 9.1) Bit-1 : CKSEL1 : Set the clock source 1 (4bits to set Internal Clock see data sheet Section 9.2 Table 9.1) Bit-0 : CKSEL0 : Set the clock source 0 (4bits to set Internal Clock see data sheet Section 9.2 Table 9.1) Bits 7 6 5 4 | 3 2 1 0 BCD 8 4 2 1 | 8 4 2 1 ----------------- 0 1 0 0 | 0 0 1 0 = 62 1MHz 1 1 1 0 | 0 0 1 0 = E2 8MHz 1 1 1 0 | 0 0 0 0 = E0 16Mhz
Now combine all 3 fuse setting: Low Byte Fuses 0xE2 CKDIV8 = 1 CKOUT = 1 SUT1 = 1 SUT0 = 0 CLSEL3 = 0 CKSEL2 = 0 CKSEL1 = 1 CKSEL0 = 0 Combining all the 8 bits, our required low fuse byte is 11100010 = 0xE2. High Byte Fuses Don't need to change the high fuse bits in order to change the clock source and operating frequency. So here is the default hex value: 0xD9 Extended Byte Fuse By default all the bits are set as 1 (Not Set unprogrammed). 0xFF
lfuse=0xE2 : hfuse=0xD9 : efuse:0xFF Now lets flash this to the ATmega328p avrdude -p m328p -c usbtiny -v -U lfuse:w:0xE2:m -U hfuse:w:0xD9:m -U efuse:w:0xFF:m
Memory Lock Bits avrdude -c usbasp -P usb -p m328p -U lock:w:0x00:m -v
Lock bits (LB1 and LB2) when low should prevent hackers from stealing your firmware. It is still possible for hackers to reverse engineer your code. To clear the Lock bits, a complete Chip Erase is required, which erase the Flash memory