Conditional inclusion

Beta Testing discussion on mikroPascal PRO for PIC32.
Post Reply
Author
Message
LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

Conditional inclusion

#1 Post by LGR » 21 Jul 2011 06:57

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. :?
If you know what you're doing, you're not learning anything.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Conditional inclusion

#2 Post by filip » 21 Jul 2011 13:23

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.

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

Re: Conditional inclusion

#3 Post by LGR » 21 Jul 2011 16:02

Now set the processor to PIC32MX320F32H.

See the problem? It objects to TRISA regardless of whether LV32MXv6 or Protoboard is uncommented.
If you know what you're doing, you're not learning anything.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Conditional inclusion

#4 Post by filip » 26 Jul 2011 15:22

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.

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

Re: Conditional inclusion

#5 Post by LGR » 26 Jul 2011 17:57

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.
If you know what you're doing, you're not learning anything.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: Conditional inclusion

#6 Post by filip » 27 Jul 2011 08:39

Hi,

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

Regards,
Filip.

Post Reply

Return to “mikroPascal PRO for PIC32 Beta Testing”