[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
3.17.4.3 AVR Built-in Macros
GCC defines several built-in macros so that the user code can test
for the presence or absence of features. Almost any of the following
built-in macros are deduced from device capabilities and thus
triggered by the -mmcu=
command-line option.
For even more AVR-specific built-in macros see AVR Named Address Spaces and AVR Built-in Functions.
__AVR_ARCH__
Build-in macro that resolves to a decimal number that identifies the architecture and depends on the
-mmcu=mcu
option. Possible values are:2
,25
,3
,31
,35
,4
,5
,51
,6
,102
,104
,105
,106
,107
for mcu=
avr2
,avr25
,avr3
,avr31
,avr35
,avr4
,avr5
,avr51
,avr6
,avrxmega2
,avrxmega4
,avrxmega5
,avrxmega6
,avrxmega7
, respectively. If mcu specifies a device, this built-in macro is set accordingly. For example, with-mmcu=atmega8
the macro will be defined to4
.__AVR_Device__
Setting
-mmcu=device
defines this built-in macro which reflects the device’s name. For example,-mmcu=atmega8
defines the built-in macro__AVR_ATmega8__
,-mmcu=attiny261a
defines__AVR_ATtiny261A__
, etc.The built-in macros’ names follow the scheme
__AVR_Device__
where Device is the device name as from the AVR user manual. The difference between Device in the built-in macro and device in-mmcu=device
is that the latter is always lowercase.If device is not a device but only a core architecture like
avr51
, this macro will not be defined.__AVR_XMEGA__
The device / architecture belongs to the XMEGA family of devices.
__AVR_HAVE_ELPM__
The device has the the
ELPM
instruction.__AVR_HAVE_ELPMX__
The device has the
ELPM Rn,Z
andELPM Rn,Z+
instructions.__AVR_HAVE_MOVW__
The device has the
MOVW
instruction to perform 16-bit register-register moves.__AVR_HAVE_LPMX__
The device has the
LPM Rn,Z
andLPM Rn,Z+
instructions.__AVR_HAVE_MUL__
The device has a hardware multiplier.
__AVR_HAVE_JMP_CALL__
The device has the
JMP
andCALL
instructions. This is the case for devices with at least 16 KiB of program memory.__AVR_HAVE_EIJMP_EICALL__
__AVR_3_BYTE_PC__
The device has the
EIJMP
andEICALL
instructions. This is the case for devices with more than 128 KiB of program memory. This also means that the program counter (PC) is 3 bytes wide.__AVR_2_BYTE_PC__
The program counter (PC) is 2 bytes wide. This is the case for devices with up to 128 KiB of program memory.
__AVR_HAVE_8BIT_SP__
__AVR_HAVE_16BIT_SP__
The stack pointer (SP) register is treated as 8-bit respectively 16-bit register by the compiler. The definition of these macros is affected by
-mtiny-stack
.__AVR_HAVE_SPH__
__AVR_SP8__
The device has the SPH (high part of stack pointer) special function register or has an 8-bit stack pointer, respectively. The definition of these macros is affected by
-mmcu=
and in the cases of-mmcu=avr2
and-mmcu=avr25
also by-msp8
.__AVR_HAVE_RAMPD__
__AVR_HAVE_RAMPX__
__AVR_HAVE_RAMPY__
__AVR_HAVE_RAMPZ__
The device has the
RAMPD
,RAMPX
,RAMPY
,RAMPZ
special function register, respectively.__NO_INTERRUPTS__
This macro reflects the
-mno-interrupts
command line option.__AVR_ERRATA_SKIP__
__AVR_ERRATA_SKIP_JMP_CALL__
Some AVR devices (AT90S8515, ATmega103) must not skip 32-bit instructions because of a hardware erratum. Skip instructions are
SBRS
,SBRC
,SBIS
,SBIC
andCPSE
. The second macro is only defined if__AVR_HAVE_JMP_CALL__
is also set.__AVR_SFR_OFFSET__=offset
Instructions that can address I/O special function registers directly like
IN
,OUT
,SBI
, etc. may use a different address as if addressed by an instruction to access RAM likeLD
orSTS
. This offset depends on the device architecture and has to be subtracted from the RAM address in order to get the respective I/O address.__WITH_AVRLIBC__
The compiler is configured to be used together with AVR-Libc. See the
--with-avrlibc
configure option.
[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on October 19, 2013 using texi2html 5.0.