The three commands to write the fuse in a new Atmega128L:
$ uisp -dprog=stk500 -dpart=ATmega128 -dserial=/dev/ttyS0
--wr_fuse_e=0xff
$ uisp -dprog=stk500 -dpart=ATmega128 -dserial=/dev/ttyS0
--wr_fuse_h=0xD9
$ uisp -dprog=stk500 -dpart=ATmega128 -dserial=/dev/ttyS0
--wr_fuse_l=0xfe
Note to read fuses :
$# uisp -dprog=stk500 -dpart=ATmega128 -dserial=/dev/ttyS0 --rd_fuses
Here is the explanation of the fuses:
1)--wr_fuse_e=0xff :
* disable M103 Mode.THis allows us to use the extra features of
atmega128 and peripherals associated with them
*disable watch dog timer enable by default , u can always enable it in
software without changing this fuse
2)--wr_fuse_h=0xD9
* diasble JTAG : beause 1)we are not using JTAG though its a great real
time testing tool to have; 2)it shall interfere with the ADC and ADC
shall give wrong readings.
* CLOCKOPT = 1 we need it for our clock 4MHz
*rest defaults are fine
3)--wr_fuse_l=0xfe
*SUT : start up time after MCU reset around 65ms for a Xtal oscillator
(sut =11 clkopt =1)
*CLKSEL[3:1] = 111 needed to use external xrystal range 3-8Mhz with a
load cap of 20pf . Our xtal is 4mhz with a load cap of 20pf
*rest defaults are ok.
NOTE!!!! : NEVER TOUCH THE LOCK BITS. CHANGING THEM IS NORMALLY NEVER
NEEDED. THE MCU WILL BECOME UNPROGRAMMABLE IF U PROGRAM THEM
INCORRECTLY BY MISTAKE !
Fuses are non-volatile memory so u need to reprogram them only once.