The CONFIG statement is used to configure the various hardware devices.
Some CONFIG statements depend on the processor platform. Since some platforms have unique hardware not found on other platforms.
DIRECTIVE |
RE-USABLE |
NORMAL AVR |
XMEGA |
XTINY/MEGAX/AVRX |
XMEGA ONLY |
XTINY/UPDI ONLY |
NO |
X |
X |
X |
|
|
|
YES |
|
X |
|
X |
|
|
YES |
X |
|
|
|
|
|
CONFIG ACx 2083 NEW |
YES |
|
|
X |
|
X |
NO |
X |
|
|
|
|
|
YES |
|
X |
|
X |
|
|
CONFIG ADC0|ADCx 2083 NEW |
YES |
|
|
X |
|
X |
NO |
X |
|
|
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
|
|
|
|
|
YES |
X |
|
|
|
|
|
YES |
X |
|
|
|
|
|
CONFIG CLOCK 2083 ENHANCED |
NO |
X |
X |
X |
|
|
YES |
X |
|
|
|
|
|
CONFIG COM1 2083 ENHANCED |
YES |
X |
X |
X |
|
|
CONFIG COM2 also COM3 - COM8 |
YES |
X |
X |
X |
|
|
YES |
X |
X |
X |
|
|
|
YES |
|
X |
|
X |
|
|
CONFIG DACX 2083 NEW |
YES |
|
|
X |
|
X |
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
X |
|
|
|
YES |
|
X |
|
X |
|
|
YES |
|
X |
|
X |
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
|
|
X |
|
x |
|
|
|
|
X |
|
x |
|
|
NO |
|
X |
X |
X |
|
|
NO |
X |
X |
X |
|
|
|
CONFIG EVENT_SYSTEM XMEGA |
YES |
|
X |
|
X |
|
CONFIG EVENT_SYSTEM XTINY 2083 NEW |
YES |
|
|
X |
|
X |
NO |
X |
|
|
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
|
|
X |
X |
X |
|
NO |
X |
X |
X |
|
|
|
NO |
X |
|
|
|
|
|
YES |
X |
X |
X |
|
|
|
NO |
X |
|
|
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
YES |
X |
X |
X |
|
|
|
YES |
X |
X |
X |
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
CONFIG OPAMP 2085 NEW |
YES |
|
|
X |
|
X |
CONFIG OSC XMEGA |
YES |
|
X |
X |
|
|
CONFIG OSC XTINY 2085 NEW |
YES |
|
|
X |
|
|
YES |
X |
X |
X |
|
|
|
CONFIG PORT_MUX 2084 NEW |
YES |
|
|
X |
|
X |
YES |
X |
X |
X |
|
|
|
NO |
|
X |
|
X |
|
|
CONFIG PRIORITY XMEGA |
YES |
|
X |
|
X |
|
CONFIG PRIORITY XTINY 2083 NEW |
YES |
|
|
X |
|
X |
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
|
|
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
|
|
|
|
|
NO |
|
|
X |
|
X |
|
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
|
|
|
|
NO |
X |
X |
X |
|
|
|
YES |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
|
|
|
|
|
YES |
|
X |
X |
X |
|
|
CONFIG STRCHECK 2086 NEW |
NO |
X |
X |
X |
|
|
NO |
X |
X |
X |
|
|
|
CONFIG SYSCLOCK XMEGA |
YES |
|
X |
|
X |
|
CONFIG SYSCLOCK XTINY 2083 NEW |
YES |
|
|
X |
|
X |
YES |
|
X |
X |
X |
|
|
YES |
|
|
X |
|
X |
|
CONFIG TCB0, TCB1 2084 NEW |
YES |
|
|
X |
|
X |
CONFIG TCD0 2084 NEW |
YES |
|
|
X |
|
X |
NO |
X |
X |
X |
|
|
|
YES |
X |
X |
X |
|
|
|
NO |
X |
|
|
|
|
|
NO |
|
X |
|
x |
|
|
YES |
X |
|
|
|
|
|
YES |
X |
|
|
|
|
|
YES |
X |
|
|
|
|
|
NO |
X |
|
|
|
|
|
NO |
X |
|
|
|
|
|
YES |
X |
X |
X |
|
|
|
YES |
|
X |
|
X |
|
|
CONFIG VREF XTINY 2083 NEW |
YES |
|
|
X |
|
X |
CONFIG VREGPWR AVRX 2085 NEW |
YES |
|
|
X |
|
X |
YES |
X |
X |
X |
|
|
|
NO |
X |
X |
X |
|
|
|
NO |
X |
|
|
|
|
|
YES |
X |
X |
X |
|
|
|
YES |
X |
X |
|
|
|
|
CONFIG ZCDx 2085 NEW |
YES |
|
|
X |
|
X |
Some CONFIG directives are intended to be used once. Others can be used multiple times. For example you can specify that a port must be set to input after you have specified that it is used as an input.
You cannot change the LCD pins during run time. In that case the last specification will be used or an error message will be displayed.
Some configuration commands are only available to the Xmega. An X in the 'Xmega Only' column indicates that the command can only be used for an Xmega processor.
Some configuration commands are exclusive for the Xtiny processors. An X in the 'Xtiny Only' column indicates that the commands can only be used for an Xtiny processor.
With XTYINY we also mean MEGAX and AVRX.
PRESERVE and OVERWRITE
In version 2084 a part of the hard coded option logic is moved to the DAT files.
Some CONFIG statements like CONFIG PORT_MUX have a new value : PRESERVE or OVERWRITE.
Other CONFIG statements might have an option named REGMODE. This REGMODE option has the same possible values : PRESERVE and OVERWRITE.
So what is this OVERWRITE or PRESERVE about?
When you configure the various options for a piece of hardware, the compiler will convert these options to the proper values and write this to the proper registers.
Only registers that are changed will be written too. But normally the whole register will be written too.
When a register sets just one option for example the clock speed, that is no problem. But when the register also has a few bits that set other hardware it might become a problem.
When you create the initial CONFIG statement there is no problem since all required bits will be set. But if you want to change a configuration later and you want to change just a single part of the configuration you could erase an option.
Lets add a simple sample. Assume there is a register named REGCTRLA and it has 8 bits. The 3 lower bits are used to set the pre-scaler. The upper 1 bit is used to enable some output pin.
BIT 7 |
BIT 6 |
BIT 5 |
BIT 4 |
BIT 3 |
BIT 2 |
BIT 1 |
BIT 0 |
O |
x |
x |
x |
x |
S |
S |
S |
The x mean don't care. It does not mean what we write to it.
Now when you would : CONFIG TEST=DUMMY, PRESCALER=2, OUTPUT=ENABLED
Here you configure all the bits in the register. So it is not needed to preserve any bits, the compiler can simply write the proper value to the register.
When REGMODE is not used it is the same as OVERWRITE and the same as : CONFIG TEST=DUMMY, PRESCALER=2, OUTPUT=ENABLED, REGMODE=OVERWRITE
Here all the bits will be written. But also when you use : CONFIG TEST=DUMMY, PRESCALER=2
This has the implicit OVERWRITE. What happens however is that only the prescaler value is provided. Since there is no preservation for other bits, the compiler will write a zero for the P bit.
And that is why the PRESERVE option exist : it will load the register value, alter it, and write it back. This will use more code.
When you use the default OVERWRITE mode the compiler will try to re-use register values. This also means that the compiler output might vary depending on the settings !
For example when you set an option that need to write to 3 registers, and all registers values are different, 3 registers are loaded with those values and written to the hardware registers.
But when the options you select result in a similar values, it is not needed to load the same value multiple times, and a different register will be used.
So the resulting binary might become bigger/smaller depending on the options.