| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| TCC 
 
 
 Joined: 10 Feb 2010
 Posts: 9
 
 
 
			    
 
 | 
			
				| Problem presetting data into data EEPROM |  
				|  Posted: Fri Apr 23, 2010 3:20 am |   |  
				| 
 |  
				| Hi, 
 I need to preset some data into data EEPROM and from CCS Help manual, there is something like #rom  0x2100={01,02,03,04,05,06,07}.
 I tried it in my program, it couldn't work. Anyone can help?
 
 I am currently using PIC16F1827, compiled with MPLAB PCM V4.106
 
 Thanks
 |  | 
	
		|  | 
	
		| FvM 
 
 
 Joined: 27 Aug 2008
 Posts: 2337
 Location: Germany
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Apr 23, 2010 4:21 am |   |  
				| 
 |  
				| "something like" isn't wrong but not particularly correct for this device.. Address 0x2100 is in the middle of the device's program flash and actually couldn't work. Microchip has programming specifications for each device. Unfortunately,
 the respective document doesn't tell about EEPROM address mapping. I guess, it's 0x8100.
 |  | 
	
		|  | 
	
		| hmmpic 
 
 
 Joined: 09 Mar 2010
 Posts: 314
 Location: Denmark
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Apr 23, 2010 7:44 am |   |  
				| 
 |  
				| For my 18F14K it's #ROM int8 0xF00000={0x01} |  | 
	
		|  | 
	
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Apr 23, 2010 11:33 am |   |  
				| 
 |  
				| The data eeprom address is given in the 16F1827 Programming Specification, which can be downloaded on this page:
 http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en538963
 
 See this section:
 
  	  | Quote: |  	  | 7.3 Data EEPROM
 The physical address range of the 256 byte data
 memory is 0000h-00FFh. However, these addresses
 are logically mapped to address 1E000h-1E1FFh in the
 hex file. This provides a way of differentiating between
 the data and program memory locations in this range.
 The format for data memory storage is one data byte
 per address location, LSb aligned.
 | 
 To get the physical address in the PIC, divide the Hex file address by 2.
 This means the data eeprom starts at 0xF000.
 
 You can verify this in the MPLAB simulator by compiling the test program
 shown below.  Then go to the View menu, and then to EEPROM, and you'll
 see it's right there: 01 02 03 04 05
 
  	  | Code: |  	  | #include <16F1827.h>
 #fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
 #use delay(clock=4000000)
 
 #rom 0xF000 = {1,2,3,4,5}
 
 //============================
 void main()
 {
 
 
 while(1);
 }
 
 | 
 |  | 
	
		|  | 
	
		| pha555 
 
 
 Joined: 17 Sep 2003
 Posts: 1
 
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Sat Apr 24, 2010 3:49 pm |   |  
				| 
 |  
				| Thanks very much PCM programmer. 
 I spent a good deal of time and solved my problem when I found your post.
 
 Cheers.
 
 Peter Anderson
 |  | 
	
		|  | 
	
		| andrewg 
 
 
 Joined: 17 Aug 2005
 Posts: 316
 Location: Perth, Western Australia
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Sat Apr 24, 2010 10:57 pm |   |  
				| 
 |  
				| The following works too (in my 4.095, anyway): 
  	  | Code: |  	  | #rom getenv("EEPROM_ADDRESS")={ | 
 _________________
 Andrew
 |  | 
	
		|  | 
	
		|  |