XC8 compiler, variable at I/O register region (GPIOR)

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Microchip Studio, XC8 compiler, ATMEGA328PB

 

Why this not working:

 

volatile uint8_t bFlags __attribute__((io_low(0x1E))); // GPIOR0

I have warrning:

warning: 'io_low' attribute address out of range or not bit addressable [-Wattributes]
		 volatile uint8_t bFlags __attribute__((io_low(0x1E)));

and variable is placed in RAM:

  bFlags=0xAA;
 15c:	9a ea       	ldi	r25, 0xAA	; 170
 15e:	90 93 06 01 	sts	0x0106, r25	; 0x800106 <bFlags>

 

I trying to translate such code from IAR IDE:

union
{
  uint8_t bFlags;
  struct
  {
    uint8_t MyFlag:1;
    uint8_t b1:1;
    uint8_t b2:1;
    uint8_t b3:1;
    uint8_t b4:1;
    uint8_t b5:1;
    uint8_t b6:1;
    uint8_t b7:1;
  };
} @ (0x001E);  //GPIO0

 

This topic has a solution.
Last Edited: Sun. Dec 13, 2020 - 03:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

use

0x1E+0x20, or

SFR_IO8(0x1E) or

GPIOR0

 

The latter two require include <avr/io.h>

For that chip, the registers are included in the data space, so 0x1E is pointing to a register.

Last Edited: Sat. Dec 12, 2020 - 10:02 PM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

 

Thanks it's works.