CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC24HJ128 Invalid Pre-Processor directive Invalid Pin

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tepes



Joined: 25 Jan 2012
Posts: 18

View user's profile Send private message

PIC24HJ128 Invalid Pre-Processor directive Invalid Pin
PostPosted: Fri Feb 24, 2012 9:24 am     Reply with quote

Hello everybody!

I want to use pins C9 and C8 for communication but I am geting this eror: Invalid Pre-Processor directive Invalid Pin (chip)!

I get no eror if I use different pins!
In the .h file the only pins defined were C1 and C2 so I have defined the rest of the C pins like so:
Code:

#define PIN_C1  5777
#define PIN_C2  5778
#define PIN_C8  5784
#define PIN_C9  5785

Here is a code example:
Code:


#define PORT_S PIN_B3

#if !defined(__PCD__)
#error This example will only compile for the PCD 24 bit compiler
#endif
#include <24HJ128GP504.h>

#fuses HS,NOWDT,noprotect
//#fuses FRC,FRC_PLL,NOWDT,NOPROTECT,
#use delay(clock=7350000)
//IT works with the following code:
#pin_select U1TX = PIN_C2
#pin_select U1RX = PIN_C1
#use rs232(baud=9600, xmit=PIN_C2, rcv=PIN_C1,parity=N,bits=8)

//IT does not work with the following code:
/*#pin_select U1TX = PIN_C9
#pin_select U1RX = PIN_C8
#use rs232(baud=9600, xmit=PIN_C9, rcv=PIN_C8,parity=N,bits=8) */


#include <stdlib.h>
#include <stdio.h>


void main(){

   
    setup_spi(FALSE);                         
    setup_wdt(WDT_OFF);                       
                 
    setup_low_volt_detect(FALSE);                 
    SET_TRIS_B(0xFF);
    // B7,B6,B5,B4 are outputs
    // B15,B14,B13,B12,B11,B10,B9,B8, B3,B2,B1,B0 are inputs
    setup_timer1(TMR_INTERNAL|TMR_DIV_BY_1);          // Internal clock

do {
   printf("Message\n\r");
   delay_ms(500);

   } while (TRUE);

}

Any sugestion greatly appreciated! Thank you!
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Fri Feb 24, 2012 9:58 am     Reply with quote

Do you have the command line compiler, or the IDE?.
You can fix this in the IDE, with the device editor, simply telling it that the extra pins exist. Each chip has an entry in a database (the devices.dat file), specifying what features it has (pins, peripherals etc.), pin numbers are 'cross checked' with the database before you can use them. There are quite a few oddities like this with the database especially on newer chips, where entries are not complete. 'Classic' is (for example) the PIC 18Fx550 chips, where the 4.3v brownout is missing, which just happens to be the most useful one for USB....
Which 24HJ128 variant are you using?. The GP206, and 506, _do_ only have C1, and C2, and checking the device files, all the other have at least some higher pins defined in current compilers.

Best Wishes
tepes



Joined: 25 Jan 2012
Posts: 18

View user's profile Send private message

PostPosted: Fri Feb 24, 2012 10:13 am     Reply with quote

I use GP504 and I dont have the IDE...
I have defined in the .h other pins for ex. PIN_A0 to PIN_A8 and I get no error when using them...Like I said, I get this error just for pins C8 and C9!

Thank you!
jeremiah



Joined: 20 Jul 2010
Posts: 1354

View user's profile Send private message

PostPosted: Fri Feb 24, 2012 1:20 pm     Reply with quote

One thing you can try as a work around is manually set the pin selects yourself. It might require a small block of assembly, but if you have to use those pins, that is one way that might work (see page 140 of the data sheet).
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Sat Feb 25, 2012 3:30 am     Reply with quote

What compiler version?.
The current compilers do have these pins on the 504.
You must have a very early version when support for these chips was added. Have tracked right back to 4.099, and the pins are there.
If you legitimately own the compiler CCS will do an upgrade for this, either supplying a .dat file, or even possibly a full upgrade.

You can always talk to individual pins using the 'trick' of a bit mask, and pin number/8. So:
Code:

#define outputhigh_expin(x) bit_set(*(x/8),x&7)
#define outputlow_expin(x) bit_clear(*(x/8),x&7)

However you have to control the tris yourself, and can't use these for things like comms.
Seriously if you compiler is that old, it is likely to have a lot of other faults as well.

Best Wishes
tepes



Joined: 25 Jan 2012
Posts: 18

View user's profile Send private message

PostPosted: Mon Feb 27, 2012 2:45 am     Reply with quote

First off all I would like to thank you for your answers! I will try to use them in order to solve my problem!

I am using MPLAB version 8.80!

One more thing: when i comand the pins like this:
Quote:
if(LOGIC)
output_high(PIN_C9);
else
output_low(PIN_C9);


I get the correct signal on the scope: so I can use the pins but not like this:
Quote:

#pin_select U1TX = PIN_C9
#pin_select U1RX = PIN_C8
#use rs232(baud=9600, xmit=PIN_C9, rcv=PIN_C8,parity=N,bits=8)

In the second example I am getting the error!
jeremiah



Joined: 20 Jul 2010
Posts: 1354

View user's profile Send private message

PostPosted: Mon Feb 27, 2012 10:20 am     Reply with quote

He means what CCS compiler version are you using? MPLAB is the IDE. The CCS compiler version is located at the beginning of the LST file generated.

I tossed your code into 4.129 and it compiled the RS232 code with PIN_C9 and PIN_C8 without any problem. It didn't like your call to setup_low_volt_detect() though, so I commented that part out.

As a side note, if you do manage to get it to compile, I would suggest using:
Code:

#pin_select U1TX = PIN_C9
#pin_select U1RX = PIN_C8
#use rs232(UART1,baud=9600, parity=N,bits=8,ERRORS)


instead of
Code:

#pin_select U1TX = PIN_C9
#pin_select U1RX = PIN_C8
#use rs232(baud=9600, xmit=PIN_C9, rcv=PIN_C8,parity=N,bits=8)


Answer back with which CCS compiler revision you have.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Mon Feb 27, 2012 11:49 am     Reply with quote

Coding of #pin_selects isn't a user editable feature in the device database. Missing features or errors have to be fixed by CCS. There have been various problems related to #pin_select with previous compiler versions, not all updates are noted in the version log.

#pin_select functionality of PCD can be however completely bypassed by writing peripheral select registers directly in your code.
tepes



Joined: 25 Jan 2012
Posts: 18

View user's profile Send private message

PostPosted: Tue Feb 28, 2012 2:15 am     Reply with quote

Sorry for the confusion! I use CCS PCD C Compiler, Version 4.084! So it looks like this is the problem! I did not realise that this CCS version is that old...but it looks like you all use 4.099+
Once again, thank you all for your help!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group