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

PCH pointers

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



Joined: 08 Sep 2003
Posts: 49
Location: Concord NH

View user's profile Send private message Send e-mail Visit poster's website

PCH pointers
PostPosted: Mon Oct 28, 2002 3:00 pm     Reply with quote

Got the following code for the PCH compiler (18F248):

#define start_node_address 0X200
#define end_node_address 0X2FF

int *node_info;

node_info = start_node_address;

The above code will not compile and I will get this error:

Constant out of the valid range

If I do the following it will compile:

#define start_node_address 0X100
#define end_node_address 0X1FF

OR if I do this it will compile:

int32 *node_info;

long int *node_info; will not compile.

The above solutions are no solutions at all. I want to use the memory from 200 to 2FF and I believe int32 *node_info will give me a pointer to a double (instead of an interger).

any thoughts.
___________________________
This message was ported from CCS's old forum
Original Post ID: 8247
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: PCH pointers
PostPosted: Mon Oct 28, 2002 3:22 pm     Reply with quote

:=Got the following code for the PCH compiler (18F248):
:=
:= #define start_node_address 0X200
:= #define end_node_address 0X2FF
:=
:= int *node_info;
:=
:= node_info = start_node_address;
:=
:=The above code will not compile and I will get this error:
:=
:= Constant out of the valid range
:=
:=If I do the following it will compile:
:=
:= #define start_node_address 0X100
:= #define end_node_address 0X1FF
:=
:=OR if I do this it will compile:
:=
:= int32 *node_info;
:=
:=long int *node_info; will not compile.
:=
:=The above solutions are no solutions at all. I want to use the memory from 200 to 2FF and I believe int32 *node_info will give me a pointer to a double (instead of an interger).
:=
:=any thoughts.
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8249
Carlos Barberis
Guest







Re: PCH pointers
PostPosted: Mon Oct 28, 2002 4:16 pm     Reply with quote

Pointers to constants are not permitted, see pg 51 of CCS manual
:=Got the following code for the PCH compiler (18F248):
:=
:= #define start_node_address 0X200
:= #define end_node_address 0X2FF
:=
:= int *node_info;
:=
:= node_info = start_node_address;
:=
:=The above code will not compile and I will get this error:
:=
:= Constant out of the valid range
:=
:=If I do the following it will compile:
:=
:= #define start_node_address 0X100
:= #define end_node_address 0X1FF
:=
:=OR if I do this it will compile:
:=
:= int32 *node_info;
:=
:=long int *node_info; will not compile.
:=
:=The above solutions are no solutions at all. I want to use the memory from 200 to 2FF and I believe int32 *node_info will give me a pointer to a double (instead of an interger).
:=
:=any thoughts.
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8251
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: PCH pointers
PostPosted: Mon Oct 28, 2002 6:42 pm     Reply with quote

He is not doing a pointer to a constant.
A pointer to a constant would be something like this:

char const mystring[6]={"Hello"}
ptr = mystring;

He is only assigning an address.

Regards,
Mark

:=Pointers to constants are not permitted, see pg 51 of CCS manual
:=:=Got the following code for the PCH compiler (18F248):
:=:=
:=:= #define start_node_address 0X200
:=:= #define end_node_address 0X2FF
:=:=
:=:= int *node_info;
:=:=
:=:= node_info = start_node_address;
:=:=
:=:=The above code will not compile and I will get this error:
:=:=
:=:= Constant out of the valid range
:=:=
:=:=If I do the following it will compile:
:=:=
:=:= #define start_node_address 0X100
:=:= #define end_node_address 0X1FF
:=:=
:=:=OR if I do this it will compile:
:=:=
:=:= int32 *node_info;
:=:=
:=:=long int *node_info; will not compile.
:=:=
:=:=The above solutions are no solutions at all. I want to use the memory from 200 to 2FF and I believe int32 *node_info will give me a pointer to a double (instead of an interger).
:=:=
:=:=any thoughts.
:=:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8255
R.J.Hamlett
Guest







Re: PCH pointers
PostPosted: Tue Oct 29, 2002 3:15 am     Reply with quote

:=Got the following code for the PCH compiler (18F248):
:=
:= #define start_node_address 0X200
:= #define end_node_address 0X2FF
:=
:= int *node_info;
:=
:= node_info = start_node_address;
:=
:=The above code will not compile and I will get this error:
:=
:= Constant out of the valid range
:=
:=If I do the following it will compile:
:=
:= #define start_node_address 0X100
:= #define end_node_address 0X1FF
:=
:=OR if I do this it will compile:
:=
:= int32 *node_info;
:=
:=long int *node_info; will not compile.
:=
:=The above solutions are no solutions at all. I want to use the memory from 200 to 2FF and I believe int32 *node_info will give me a pointer to a double (instead of an interger).
:=
:=any thoughts.
:=
You don't say which compiler version. I suspect this is a version of a fault I had with the CCS compiler, which has now (largely) been fixed, where if I generated pointers to an integer, I found the compiler generating 8 bit pointers. However if I generated pointers to int16 values, it used a 16bit pointer, and if I went to using pointers to int32 values it used 32bit pointers!.
This was fixed a while ago, but when I ran into this problem, I found the fault only affected certain pointer operations, so I could 'code round' the problem, by declaring my pointers to be to a larger data type, and then casting the resulting pointer to the right type in use.
So something like:

int32 *node_info;
node_info=start_node_address;

Then when I wanted to use the pointer, employing:

val=(int *)start_node_address;

The only problem with this, is that address arithmetic, then doesn't follow the normal rules...

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 8267
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: PCH pointers
PostPosted: Tue Oct 29, 2002 6:49 am     Reply with quote

I know I typed a response but here is what I found.

The compiler would not allow a value greater than 0x1FF.
However this works great

#byte start_node = 0x200
#define start_node_address &start_node
#define end_node_address &start_node + 0xFF
int *node_info;

node_info = start_node_address;


:=:=Got the following code for the PCH compiler (18F248):
:=:=
:=:= #define start_node_address 0X200
:=:= #define end_node_address 0X2FF
:=:=
:=:= int *node_info;
:=:=
:=:= node_info = start_node_address;
:=:=
:=:=The above code will not compile and I will get this error:
:=:=
:=:= Constant out of the valid range
:=:=
:=:=If I do the following it will compile:
:=:=
:=:= #define start_node_address 0X100
:=:= #define end_node_address 0X1FF
:=:=
:=:=OR if I do this it will compile:
:=:=
:=:= int32 *node_info;
:=:=
:=:=long int *node_info; will not compile.
:=:=
:=:=The above solutions are no solutions at all. I want to use the memory from 200 to 2FF and I believe int32 *node_info will give me a pointer to a double (instead of an interger).
:=:=
:=:=any thoughts.
:=:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8268
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