Page 1 of 1

Conditional inclusion

Posted: 21 Jul 2011 06:57
by LGR
I have a program which has conditions for the LV32MXv6 development board and the target processor.

Code: Select all

// Uncomment the appropriate flag:
{$DEFINE LV32MXv6} //Declarations for LV32MX v6 develpment board using
                   // PIC32MX460F512L

//{$DEFINE Protoboard} // Declarations for actual prototype board
This is ok, as long as the PIC32MC460F512l is selected, but we have a problem when the target PIC32MX320F32H is selected:

Code: Select all

{$IFDEF LV32MXv6}
  {Initialization specifically for LV-32MX v6 develpment board
  using PIC32MX460F512L. For a summary of all I/O pins and how the TRIS registers are derived
  see here: }
  TRISA := 64;  TRISB := 62;  TRISC := 16;  TRISD := 0;
  TRISE := 0;   TRISF := 0;   TRISG := 128; AD1PCFG := 0xFFFF;
{$ELSE}
  {$IFDEF Protoboard}
  {Initialization for actual prototype board
  For a summary of all I/O pins and how the TRIS registers are derived
  see herefig }
  TRISB := 62; TRISC := 0;  TRISD := 0;
  TRISE := 128; TRISF := 4;  TRISG := 128; AD1PCFG := 0xFFC1;
The problem is that the compiler objects to the TRISA in the upper clause even when Protoboard is selected, because the PIC32MX320F32H doesn't have a port A. The compiler shouldn't object to undeclared variables in a non-operative clause, but it does. :?

Re: Conditional inclusion

Posted: 21 Jul 2011 13:23
by filip
Hi,

I have tried this in the following way in the 1.80 version of the compiler and it worked OK :

Code: Select all

program test;

// Uncomment the appropriate flag:
//{$DEFINE LV32MXv6} //Declarations for LV32MX v6 develpment board using
                   // PIC32MX460F512L

{$DEFINE Protoboard} // Declarations for actual prototype board

begin
{$IFDEF LV32MXv6}
  {Initialization specifically for LV-32MX v6 develpment board
  using PIC32MX460F512L. For a summary of all I/O pins and how the TRIS registers are derived
  see here: }
  TRISA := 64;  TRISB := 62;  TRISC := 16;  TRISD := 0;
  TRISE := 0;   TRISF := 0;   TRISG := 128; AD1PCFG := 0xFFFF;
{$ELSE}
  {$IFDEF Protoboard}
  {Initialization for actual prototype board
  For a summary of all I/O pins and how the TRIS registers are derived
  see herefig }
  TRISB := 62; TRISC := 0;  TRISD := 0;
  TRISE := 128; TRISF := 4;  TRISG := 128; AD1PCFG := 0xFFC1;
  {$ENDIF}
{$ENDIF}
end.
Regards,
Filip.

Re: Conditional inclusion

Posted: 21 Jul 2011 16:02
by LGR
Now set the processor to PIC32MX320F32H.

See the problem? It objects to TRISA regardless of whether LV32MXv6 or Protoboard is uncommented.

Re: Conditional inclusion

Posted: 26 Jul 2011 15:22
by filip
Hi,

If I only use this directive {$DEFINE Protoboard} in the 1.80 version of the compiler ,
there are no errors when compiling this code for PIC32MX320F032H, as the PORTA code is in the other {$IFDEF} branch (which uses {$DEFINE LV32MXv6}).

Regards,
Filip.

Re: Conditional inclusion

Posted: 26 Jul 2011 17:57
by LGR
I think this is a variation on the same problem that I corresponded with Janko Kaljevic about: when I do all of that, the compiler compiles correctly, but the TRISA is still underlined. There seems to be a general problem with the underlining.

Re: Conditional inclusion

Posted: 27 Jul 2011 08:39
by filip
Hi,

It is underlined because the PIC32MX320F032H has no PORTA, therefore the Code Editor makes this red underlines.

Regards,
Filip.