AVR Fuse & Lock bytes [ATMega328/P, Arduino]

Arabinda Verma
Arabinda Verma
10.5 هزار بار بازدید - 6 سال پیش -
https://www.udemy.com/embedded-progra...

In today's lesson, we shall learn about the Fuse and lock bytes. The lesson is accompanied by a hands-on session in which you shall program the fuse and lock bytes. This will configure the atmega328 for further usage.

There are four bytes in a separate non-volatile memory area which is used to secure the code in the microcontroller and configure it.  One of those bytes is lock byte while other three are fuse bytes.
Lock byte is used to restrict the access to the Flash and EEPROM and provides security against unauthorized access to the on-chip memory. The access restriction can be applied at three levels - no restriction, disable programming, that is write operation, in parallel & serial programming modes & disable programming & verification, basically read and write operation, in both the programming modes. Lock byte is also used to restrict the access of the two sections of flash memory those are the Application section and Bootloader section. For our purpose, the desired value of the lock byte is 0x3F.

Fuse bytes are used to configure the microcontroller. There are three fuse bytes named extended fuse byte, fuse high byte and fuse low byte and are identified using efuse, hfuse & lfuse, respectively, while programming. The 5 most significant bits of efuse are unused and rest three bits are used to configure the trigger level of Brown-out detector. We shall program the fuse byte with value 0xFD.

The fuse high byte is used to enable or disable external reset, debugWire, serial program and data downloading and EEPROM data preservation through chip erase. It is also used to configure the size of bootloader section and select the reset vector. The lfuse is programmed with value 0xDE.

The fuse low byte is used to enable or disable divide clock by 8 and Clock output. It is also used to select the start-up time and clock source. We shall program the fuse byte with 0xFF.

It is important that fuse and lock bytes are programmed with the values mentioned. For example, the default value of clock select in fuse low byte selects the internal RC oscillator at 8MHz. But we are using 16MHz external crystal oscillator so the clock  select must be initialized with binary value 111.

We have already wired the base circuit with in-circuit programmer and learned about the AVRDUDE. Let's check the value of fuse and lock bytes and program those as necessary. Connect the development board to the development PC through the in-circuit programmer and use the command shown.
6 سال پیش در تاریخ 1397/10/19 منتشر شده است.
10,537 بـار بازدید شده
... بیشتر