How to bind a variable to an unused AVR I / O register using avr-gcc?

I want to bind a global variable to an unused I / O register (e.g. PORTB) using avr-gcc to reduce code size. I found out about this in the note to the AVR application AVR035 (p. 14).

In a note to the application, they use the IAR compiler and bind the variable to the I / O register as follows:

__no_init volatile uint8_t counter@0x35;

With avr-gcc, I can bind a variable to the standard register (r3 in this case) using this line:

register uint8_t counter asm("r3");

However, this does not work for I / O registers. Is there a way to do this for I / O registers?

+3
source share
1 answer

, - , , UART Baud Rate Register:

#define myGlobalVariable UBRR

, , , - . , , AVR LDS STS, SRAM Z, IN OUT...

+2

All Articles