CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Storing long string on serial EEPROM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jelodavid



Joined: 03 Apr 2005
Posts: 22
Location: Laguna Philippines

View user's profile Send private message Yahoo Messenger

Storing long string on serial EEPROM
PostPosted: Fri Aug 08, 2008 11:42 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Aug 10, 2008 1:39 pm     Reply with quote

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

View user's profile Send private message Yahoo Messenger

PostPosted: Mon Aug 11, 2008 6:16 am     Reply with quote

Thanks a lot!Smile
souravkumarkar



Joined: 31 Dec 2011
Posts: 5
Location: Baripada

View user's profile Send private message Visit poster's website

received data from pc & write in eeprom
PostPosted: Sat Dec 31, 2011 2:03 pm     Reply with quote

sir,
i m try many time but result is zero .
temtronic



Joined: 01 Jul 2010
Posts: 9225
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Dec 31, 2011 2:18 pm     Reply with quote

Do you have the correct value pullup resistors on the I2C lines?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 31, 2011 2:34 pm     Reply with quote

Look at the connections for the 24LC256 eeprom in the PicDem2-Plus manual.
It's in the upper right corner, on page 25:
http://ww1.microchip.com/downloads/en/devicedoc/51275d.pdf
If you connect it the same way on your board, it should work.
incubator



Joined: 14 Jan 2012
Posts: 1
Location: California

View user's profile Send private message

PostPosted: Fri Mar 09, 2012 9:54 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Mar 10, 2012 9:07 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group