16.1 AVR GCC Toolchain
Most configuration bits are contained in device Fuse bytes. To program the fuse bits, the
Fuse API is used. To use this API, include the <avr/io.h>
header
file, which provides everything necessary to set the AVR fuses.
To program code protection configuration bits, or lock bits, the Lockbit API is used. To
use this API, include the <avr/io.h>
header file.
An example using the FUSES
and LOCKBITS
macros is provided below. For more information on the Fuse and Lockbit APIs, see:
Example: ATtiny861 MCU
// ATtiny817 Configuration Bit Settings
// 'C' source line config statements
#include <avr/io.h>
FUSES = {
0x00, // WDTCFG{PERIOD=OFF, WINDOW=OFF}
0x02, // BODCFG{SLEEP=SAMPLED, ACTIVE=DIS, SAMPFREQ=1KHz, LVL=BODLEVEL0}
0x00, // OSCCFG{OSCLOCK=CLEAR}
0x00, // Reserved
0xC4, // TCD0CFG{CMPA=CLEAR, CMPB=CLEAR, CMPC=SET, CMPD=CLEAR, CMPAEN=CLEAR, CMPBEN=CLEAR, CMPCEN=SET, CMPDEN=SET}
0xF6, // SYSCFG0{EESAVE=CLEAR, RSTPINCFG=UPDI, CRCSRC=NOCRC}
0x00, // SYSCFG1{SUT=0MS}
0x00, // APPEND
0x00, // BOOTEND
};
LOCKBITS = {
0xC5, // LOCKBIT{LB=NOLOCK}
};
The example above was generated from the Configuration Bits window ( ).
When you first open the Configuration Bits window, the data will need to be red, meaning you need to read from device memory. Use the Read Configuration Bits icon
![](GUID-0B37CAEC-A920-4164-A068-232EC5AE6D26-high.png)
![](GUID-666059E3-16BC-4B4D-8975-2BC052FD9BD9-high.png)
To preserve your settings in code, click either the Generate Source Code to Output button, to put the code in the Output window for copy-and-paste into your code, or the Insert Source Code into Editor icon
![](GUID-21D46786-104E-4976-AA22-E19DC64E2CA9-high.png)
![](GUID-51FA077F-D386-42E2-B51B-EFA970A7A31F-high.png)