News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

$define portd problem

Started by Rizwan s shaikh, Oct 28, 2022, 03:05 PM

Previous topic - Next topic

Rizwan s shaikh

Ser
$define LED1_ON PORTD.1=1'
PORTD NOT DIFINE PORTA PORTB PORTC
AND PORTE is difine
Please help me
Thankyou

Pepe


Rizwan s shaikh


John Lawton

That code snippet compiles fine for me.

top204

The $define has an empty comment character (apostrophe) at the end of its line, and this will make the $define, line continue, so the compiler will also see the line below the $define. i.e.

$define LED1_ON PORTD.1=1' <--------------------- Empty Comment Character

Rizwan s shaikh

If this line
$define LED1_ON PORTD.1=1
In basic program then ok
But place in include fail
Not define

top204

I've just tried it and it is working as expected. Remember, the preprocessor has no idea of include files. It see the code as a whole after the include files have been included into the program's listing. It is a seperate program that preprocesses the file then sends it to the compiler.

Try this... Create a file named "DefineTest.bas" with the following in it:
'
' Test a $define within an include file
'
    Device = 18F45K20
    Declare Xtal = 16
   
    Include "Test.inc"      ' Load the include file
   
    LED_ON                  ' Perform the meta-macro

Now create a file named "Test.inc", with the following in it, and save it:
$define LED_ON PORTD.0 = 1      ' Create a preprocessor meta-macro

Compile the "DefineTest.bas" program, and it will compile correctly.
 
Make sure the device does actually contain PORTD, otherwise it will always give an error on a device with less than 40 pins. Also make sure you do not have $if or $ifdef comparisons in the file that will block it with false results, otherwise, it will not be created.

Rizwan s shaikh