| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| jelodavid 
 
 
 Joined: 03 Apr 2005
 Posts: 22
 Location: Laguna Philippines
 
 
			      
 
 | 
			
				| Storing long string on serial EEPROM |  
				|  Posted: Fri Aug 08, 2008 11:42 pm |   |  
				| 
 |  
				| Hello! I'm PIC C newbie programmer. Could you give me an example program on Serial EEPROM (24LC08) that will store long string of text on it then can be retrieve or display on LCD. I'll be using PIC16F876 or PIC16F877 mcu. Many thanks in advance.... |  | 
	
		|  | 
	
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Sun Aug 10, 2008 1:39 pm |   |  
				| 
 |  
				|  	  | Quote: |  	  | Could you give me an example program on Serial EEPROM (24LC08) that will store long string of text on it then can be retrieve or display on LCD.
 | 
 Here is a simple program that does those things.
 
  	  | Code: |  	  | #include <16F877.H> #fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
 #use delay (clock=4000000)
 //#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
 
 #include "flex_lcd.c"
 
 #define EEPROM_SDA  PIN_C4
 #define EEPROM_SCL  PIN_C3
 #include <24256.c>
 
 
 char const line1[]= {"Hello World"};
 
 //=================================
 void main()
 {
 int8 i;
 int8 buffer[17];
 
 lcd_init();
 
 // Write "Hello World" to external eeprom chip.
 for(i = 0; i < sizeof(line1); i++)
 write_ext_eeprom(i, line1[i]);
 
 
 // Read characters from the external eeprom chip
 // and write them into a RAM buffer.
 for(i = 0; i < sizeof(line1); i++)
 buffer[i] = read_ext_eeprom(i);
 
 // Display the message on the LCD.
 printf(lcd_putc, buffer);
 
 while(1);
 }
 | 
 |  | 
	
		|  | 
	
		| jelodavid 
 
 
 Joined: 03 Apr 2005
 Posts: 22
 Location: Laguna Philippines
 
 
			      
 
 | 
			
				|  |  
				|  Posted: Mon Aug 11, 2008 6:16 am |   |  
				| 
 |  
				| Thanks a lot!  |  | 
	
		|  | 
	
		| souravkumarkar 
 
 
 Joined: 31 Dec 2011
 Posts: 5
 Location: Baripada
 
 
			      
 
 | 
			
				| received data from pc & write in eeprom |  
				|  Posted: Sat Dec 31, 2011 2:03 pm |   |  
				| 
 |  
				| sir, i m try many time but result is zero .
 |  | 
	
		|  | 
	
		| temtronic 
 
 
 Joined: 01 Jul 2010
 Posts: 9587
 Location: Greensville,Ontario
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Sat Dec 31, 2011 2:18 pm |   |  
				| 
 |  
				| Do you have the correct value pullup resistors on the I2C lines? |  | 
	
		|  | 
	
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 |  | 
	
		|  | 
	
		| incubator 
 
 
 Joined: 14 Jan 2012
 Posts: 1
 Location: California
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Mar 09, 2012 9:54 pm |   |  
				| 
 |  
				| The code has a little mistake, put this on the begining of the main code: 
 //================
 
 init_ext_eeprom();   // Call before the other functions are used
 
 //==================
 |  | 
	
		|  | 
	
		| PCM programmer 
 
 
 Joined: 06 Sep 2003
 Posts: 21708
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Sat Mar 10, 2012 9:07 pm |   |  
				| 
 |  
				| That routine just consists of these two lines, which set SCL and SDA to be input pins:
 
  	  | Code: |  	  | void init_ext_eeprom()
 {
 output_float(EEPROM_SCL);
 output_float(EEPROM_SDA);
 }
 
 | 
 The PIC sets all i/o pins to be inputs during power-on reset.  So it really
 isn't necessary to call that function.  It's just doing something that has
 already been done anyway by the hardware.
 |  | 
	
		|  | 
	
		|  |