| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			Douglas Richard
 
 
  Joined: 08 Sep 2003 Posts: 49 Location: Concord NH 
			
			 
			 
			 
			 
			
			
			
			
			
  
		  | 
		
			
				| PCH pointers | 
			 
			
				 Posted: Mon Oct 28, 2002 3:00 pm     | 
				     | 
			 
			
				
  | 
			 
			
				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 
			
			 
			 
			 
			
			
			
			
			
			
  
		  | 
		
			
				| Re: PCH pointers | 
			 
			
				 Posted: Mon Oct 28, 2002 3:22 pm     | 
				     | 
			 
			
				
  | 
			 
			
				:=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 | 
			 
			
				 Posted: Mon Oct 28, 2002 4:16 pm     | 
				     | 
			 
			
				
  | 
			 
			
				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 
			
			 
			 
			 
			
			
			
			
			
			
  
		  | 
		
			
				| Re: PCH pointers | 
			 
			
				 Posted: Mon Oct 28, 2002 6:42 pm     | 
				     | 
			 
			
				
  | 
			 
			
				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 | 
			 
			
				 Posted: Tue Oct 29, 2002 3:15 am     | 
				     | 
			 
			
				
  | 
			 
			
				:=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 
			
			 
			 
			 
			
			
			
			
			
			
  
		  | 
		
			
				| Re: PCH pointers | 
			 
			
				 Posted: Tue Oct 29, 2002 6:49 am     | 
				     | 
			 
			
				
  | 
			 
			
				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 | 
			 
		  | 
	
	
		  | 
	
	
		 |