| View previous topic :: View next topic   | 
	
	
	
		| Author | 
		Message | 
	
	
		
			Fro_guy Guest
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				| Ram Woes | 
			 
			
				 Posted: Tue Apr 18, 2006 8:37 am     | 
				     | 
			 
			
				
  | 
			 
			
				Is there a way to set global varrables in the ram at a certian location, so the compiler will put it in the same place every time??  I searched the forms but couldent find anything.
 
 
Thanks! | 
			 
		  | 
	
	
		  | 
	
	
		
			ckielstra
 
 
  Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands 
			
			 
			 
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Apr 18, 2006 8:47 am     | 
				     | 
			 
			
				
  | 
			 
			
				| Check the manual for the description of the #locate command. | 
			 
		  | 
	
	
		  | 
	
	
		
			Fro_Guy Guest
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Apr 18, 2006 8:54 am     | 
				     | 
			 
			
				
  | 
			 
			
				thats what i was looking for.
 
 
Thanks! | 
			 
		  | 
	
	
		  | 
	
	
		
			Fro_Guy Guest
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Apr 18, 2006 9:13 am     | 
				     | 
			 
			
				
  | 
			 
			
				When you use the locate command, i am trying to use an array.  It dosent allow you to put the brackets in for the array so i was wondering if it is only going to reserve the starting adress.  Would i have to do the #locate followed by a #reserve to save the space for the array or will the compiler know to reserve that ram?  Sorry for all the questions.
 
 
Thanks!
 
 
Fro_Guy | 
			 
		  | 
	
	
		  | 
	
	
		
			Ttelmah Guest
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Apr 18, 2006 9:41 am     | 
				     | 
			 
			
				
  | 
			 
			
				Look at the example. You don't declare the array (or any variable) with locate. Declare the array 'as normal', and then just locate the array.
 
The example, shows this with a float (4 bytes).
 
So:
 
 	  | Code: | 	 		  
 
int8 demo_array[20];
 
#locate demo_array=0x50
 
 | 	  
 
 
The 'symbol map' for this, gives:
 
 
050-063 demo_array
 
 
Best Wishes | 
			 
		  | 
	
	
		  | 
	
	
		
			treitmey
 
 
  Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI   USA 
			
			 
			 
			
			 
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Apr 18, 2006 9:42 am     | 
				     | 
			 
			
				
  | 
			 
			
				From the symbol file it looks like it resurved the whole array.
 
 	  | Code: | 	 		  #include <18f452.h>
 
#use delay(clock=40000000)
 
#use rs232(baud=19200,xmit=PIN_C0,invert,stream=DEBUG,disable_ints) // stderr(same as debug)
 
#fuses h4,nowdt,noprotect,nolvp
 
#case
 
#zero_ram
 
//---------------- main --------------------
 
void main(void){
 
  int8 array[17];
 
  #locate array=0x100;
 
  set_tris_c(0xFF);set_tris_a(0);set_tris_b(0);set_tris_d(0);set_tris_e(0);
 
  setup_adc_ports(NO_ANALOGS);
 
  fprintf(DEBUG,"1\n\r");
 
  fprintf(DEBUG,"2\n\r");
 
  fprintf(DEBUG,"3\n\r");
 
  array[2]=7;
 
  while(1){ }
 
}
 
 | 	  
 
 
 
 
 	  | Code: | 	 		  
 
000     @SCRATCH
 
001     @SCRATCH
 
001     _RETURN_
 
002     @SCRATCH
 
003     @SCRATCH
 
004     @SCRATCH
 
006     main.@SCRATCH
 
007     @PUTCHAR_1_.P1
 
008     @PUTCHAR_1_.@SCRATCH
 
100-110 main.array
 
F83     PSP_DATA
 
FBB     CCP_2_LOW
 
FBB-FBC CCP_2
 
FBC     CCP_2_HIGH
 
FBE     CCP_1_LOW
 
FBE-FBF CCP_1
 
FBF     CCP_1_HIGH
 
 
0040  @PUTCHAR_1_
 
0090  main
 
0004  @const10057
 
0018  @const10062
 
002C  @const10067
 
0090  @cinit
 
 
Project Files:
 
    C:\ccs\Projects\3200I\junk.c
 
    C:\PROGRA~1\PICC\devices\18f452.h
 
 
Units:
 
    C:\ccs\Projects\3200I\junk.c (main)
 
 
Compiler Settings:
 
    Processor:      PIC18F452
 
    Pointer Size:   16
 
    ADC Range:      0-255
 
    Opt Level:      9
 
    Short,Int,Long: 1,8,16
 
    Case Sensitive: Yes
 
 
Output Files:
 
    Errors:      C:\ccs\Projects\3200I\junk.err
 
    INHX32:      C:\ccs\Projects\3200I\junk.hex
 
    Symbols:     C:\ccs\Projects\3200I\junk.sym
 
    List:        C:\ccs\Projects\3200I\junk.lst
 
 | 	  
 
 
... beat me by 1 min. | 
			 
		  | 
	
	
		  | 
	
	
		
			Fro_Guy Guest
 
 
 
 
  
			
			
			
			
			
			
			
			
			
			
  
		  | 
		
			
				 | 
			 
			
				 Posted: Tue Apr 18, 2006 9:47 am     | 
				     | 
			 
			
				
  | 
			 
			
				Thanks for all they help guys.  I should be off tot he races now!
 
 
Thanks again!
 
 
Fro_Guy | 
			 
		  | 
	
	
		  | 
	
	
		 |