• AVR Freaks

AnsweredHot!Initialization discards 'volatile' qualifier from pointer target type

Author
poross
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2020/05/21 04:21:18
  • Location: 0
  • Status: offline
2020/07/02 01:14:10 (permalink)
0

Initialization discards 'volatile' qualifier from pointer target type

Hi,
I am a newcomer to the PIC32mx and XC32.  I am using XC32 v2.41, MPLABX v5.40, and the pic32mx570f512l.  I want to make a cable tester.  It will have 50 pins for output data.  I am using sample code at forums
 
 
I am trying to high and low pins so I have this line in my code:
typedef struct output_pin_description {
  int *lat;
  int mask;
} op;
 
op opins[32] = {
  { &LATA, 0x0001 },
  { &LATA, 0x0002 },
  { &LATA, 0x0004 },
  { &LATA, 0x0008 },
  { &LATB, 0x0001 },
  { &LATB, 0x0004 },
  { &LATB, 0x0008 },
  { &LATB, 0x0010 }
};
 
void pin_high(int no) {
  *(opins[no].lat) |= opins[no].mask;
}

void pin_low(int no) {
  *(opins[no].lat) &= ~opins[no].mask;
}

the problem (warning: initialization discards 'volatile' qualifier from pointer target type [enabled by default]{ &LATA, 0x0001 }, ^ ) appears.
 
Does anyone know how else i should be declaring the pointer to avoid this? Thanks!
#1
lachlanp
New Member
  • Total Posts : 6
  • Reward points : 0
  • Joined: 2018/03/27 02:03:54
  • Location: 0
  • Status: offline
Re: Initialization discards 'volatile' qualifier from pointer target type 2020/07/02 01:21:07 (permalink)
-2 (2)
&LATA is obviously declared as volatile. try declaring op as volatile.
#2
poross
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2020/05/21 04:21:18
  • Location: 0
  • Status: offline
Re: Initialization discards 'volatile' qualifier from pointer target type 2020/07/02 01:40:42 (permalink)
0
main.c:73:3: warning: initialization discards 'volatile' qualifier from pointer target type [enabled by default]
{ &LATA, 0x0001 },
.
.
.
main.c:80:3: warning: initialization discards 'volatile' qualifier from pointer target type [enabled by default]
{ &LATB, 0x0010 }
^

#define LATB LATB
extern volatile uint32_t LATB __attribute__((section("sfrs"), address(0xBF886130)));
#define LATA LATA
extern volatile uint32_t LATA __attribute__((section("sfrs"), address(0xBF886030)));

#3
ric
Super Member
  • Total Posts : 28365
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: Initialization discards 'volatile' qualifier from pointer target type 2020/07/02 01:44:55 (permalink) ☼ Best Answerby poross 2020/07/02 02:54:03
+6 (6)
So change
typedef struct output_pin_description {
  int *lat;
  int mask;
} op;

to match the real definition, i.e.
typedef struct output_pin_description {
  volatile uint32_t *lat;
  int mask;
} op;


I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#4
Jump to:
© 2020 APG vNext Commercial Version 4.5