| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			Guest
 
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				| Place a const at a fixed location? | 
			 
			
				 Posted: Wed Feb 10, 2010 8:12 am     | 
				     | 
			 
			
				
  | 
			 
			
				I want to place this line at fixed location in the code, how to do that?
 
 	  | Code: | 	 		  | Const char IDNr[] = {"hw:2.00 / fw:1.20"}; | 	  
 
 
hints? | 
			 
		  | 
	
	
		  | 
	
	
		
			Wayne_
 
 
  Joined: 10 Oct 2007 Posts: 681
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Feb 10, 2010 10:52 am     | 
				     | 
			 
			
				
  | 
			 
			
				| Look at #org in the help. | 
			 
		  | 
	
	
		  | 
	
	
		
			languer
 
 
  Joined: 09 Jan 2004 Posts: 144 Location: USA 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Feb 10, 2010 2:13 pm     | 
				     | 
			 
			
				
  | 
			 
			
				I've used something similar to the code shown in this post.
 
 
The location is usually the last implemented registers.
 
 
Example for 12F629:
 
 	  | Code: | 	 		  #ORG 0x3D0,0x3DF
 
const char build_rev[] = {"Rev 1.0"};   // max length = 15
 
#ORG 0x3E0,0x3EF
 
const char build_date[] = __DATE__;      // max length = 15
 
#ORG 0x3F0,0x3FF
 
const char build_time[] = __TIME__;      // max length = 15
 
 
...
 
 
printf("%s\nBuild: \%s, \%s\n\r", build_rev, build_date, build_time);
 
 | 	 
  | 
			 
		  | 
	
	
		  | 
	
	
		
			Guest
 
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Feb 10, 2010 2:45 pm     | 
				     | 
			 
			
				
  | 
			 
			
				I dont understand I cant compile it when using the #ORG xx yy statement?
 
I get error...
 
I place the statement at the top of my main.c file. | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		 | 
	
	
		  | 
	
	
		
			Guest
 
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Feb 10, 2010 3:51 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Thanks, But wont work.
 
 
I use:
 
 	  | Code: | 	 		  #org 0x300, 0x310
 
Const Char IDNr[] = "v1.0"; | 	  
 
 
And get this error:
 
 	  | Code: | 	 		  *** Error 71 "main.c" Line 444(0,1): Out of ROM, A segment or the program is too large    @const76
 
Seg 00300-00310, 0012 left, need 0022
 
 | 	  
 
 
Its the same error even if I change the #org addr space? | 
			 
		  | 
	
	
		  | 
	
	
		
			PCM programmer
 
 
  Joined: 06 Sep 2003 Posts: 21708
  
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Feb 10, 2010 3:54 pm     | 
				     | 
			 
			
				
  | 
			 
			
				| Post your PIC and your compiler version. | 
			 
		  | 
	
	
		  | 
	
	
		
			languer
 
 
  Joined: 09 Jan 2004 Posts: 144 Location: USA 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Wed Feb 10, 2010 6:22 pm     | 
				     | 
			 
			
				
  | 
			 
			
				Also post the small program...
 
 
I believe this:
 
 	  | Code: | 	 		  | Const Char IDNr[] = "v1.0"; | 	  
 
should read:
 
 	  | Code: | 	 		  | Const Char IDNr[] = {"v1.0"}; | 	  
 
 
Your address looks pretty low too:
 
 
 
Normally you would place this at the top range of the code space. | 
			 
		  | 
	
	
		  | 
	
	
		 |