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 support@ccsinfo.com

how is the page writing?

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



Joined: 18 May 2010
Posts: 78

View user's profile Send private message

how is the page writing?
PostPosted: Sun Jan 09, 2011 8:14 am     Reply with quote

Hi
I want to erase a 24c512 by a pic16f877a. I know that I must write 0xff to entire memory.
I could do it for one page not more pages.
the code is:
Code:

#bit ack_check=0x91.6
#define write_cmd 0xA0
#define read_cmd 0xA1


void erasing(int16 address,int data)
{
i2c_start();
i2c_write(write_cmd);
if(ack_check==0)
i2c_write(address>>8);
if(ack_check==0)
i2c_write(address);
if(ack_check==0)
while(j<128){
i2c_write(data);
j++;
}
if(ack_check==0)
i2c_stop();
delay_ms(10);
}
///***************************
for(k=0;k<80;k++){
erasing(k*128,0xff);
delay_ms(100);
}

but it didn't work.please help me.
thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jan 09, 2011 3:27 pm     Reply with quote

This thread has a 24LC256 eeprom driver that has functions for Page mode.
http://www.ccsinfo.com/forum/viewtopic.php?t=17787

If you want to use it with a 24LC512 eeprom, you need to do two things:
1. Change #define EEPROM_PAGE_LEN to 128.
2. Use an 18F PIC, instead of 16F877. That's because the 16877 can't
do a ram buffer larger than about 96 bytes. The 18F PICs can easily
do a 128 byte buffer.
mojsa2000



Joined: 18 May 2010
Posts: 78

View user's profile Send private message

it was solved
PostPosted: Mon Jan 10, 2011 11:13 am     Reply with quote

Hi
thanks.
I changed the code and it worked:
Quote:

#bit ack_check=0x91.6
#define write_cmd 0xA0
#define read_cmd 0xA1

void erasing(int16 address,int data)
{
i2c_start();
i2c_write(write_cmd);
if(ack_check==0)
i2c_write(address>>8);
if(ack_check==0)
i2c_write(address);
if(ack_check==0)
for(j = 0; j < 128; j++)
i2c_write(data);

if(ack_check==0)
i2c_stop();
delay_ms(10);
}
///***************************
for(k=0;k<80;k++){
erasing(k*128,0xff);
delay_ms(100);
}
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