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

2465, 24128, 24256 why driver diff?

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



Joined: 19 Jul 2004
Posts: 42
Location: Malaysia, PJ

View user's profile Send private message Send e-mail

2465, 24128, 24256 why driver diff?
PostPosted: Sat Sep 17, 2005 3:27 am     Reply with quote

Why the eeprom drivers 2465.c, 24128.c, and 24256.c are different?

I tried to modify the 2465.c and 24128.c to use on my 24LC256 EEPROM, it can work with small memory address, but I cannot write/read the larger memory bank.

A few things i don't understand:

what means?

Quote:
#define hi(x) (*(&x+1))


in 24128.c, this is for what?
Quote:
for (i=0;i<3;i++) {
i2c_start();
i2c_write(0xa0);
i2c_write(0xff);
i2c_write(0xff);
if(i==2)
i2c_write(0x2);
else
i2c_write(0x2+i);
i2c_stop();
}


why use this to send control byte to eeprom?
Quote:
i2c_write(((0xa0)|(hi(address)>>5))&0xfe);


Another question is, I found that using these drivers to write and read continuous data is not very efficient. How to modify the driver to do page write and sequential read? How to issue ACK?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 18, 2005 2:09 pm     Reply with quote

Quote:
I tried to modify the 2465.c and 24128.c to use on my 24LC256 EEPROM

You have a very old version of the compiler, that doesn't have that driver.
So just do a web search. There are many students who use the CCS
compiler, and quite often they post their code or the drivers.
So, use http://www/google.com and find it. Search for the name
of one of the functions that you know will be in the driver, and search
for CCS, and the name of the EEPROM. Try this search string:
init_ext_eeprom CCS 24LC256

Here it is:
http://www.d.hoen.ca:8080/programming/programming/AUVic2004/Development/PICC/Drivers/24256.C
Joshua Lai



Joined: 19 Jul 2004
Posts: 42
Location: Malaysia, PJ

View user's profile Send private message Send e-mail

PostPosted: Sun Sep 18, 2005 9:05 pm     Reply with quote

Oh, dear sir,

How to do page write or sequential read using this driver?

What this for?
Quote:
status=i2c_write(0xa0);
while(status==1)
{
i2c_start();
status=i2c_write(0xa0);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 18, 2005 9:48 pm     Reply with quote

Quote:
How to do page write or sequential read using this driver?

This link has some code which can write to a page:
http://www.ccsinfo.com/forum/viewtopic.php?t=17787
There is other page mode code on the forum, but it's more complicated
than the code in the link above.


Quote:

What this for?

status=i2c_write(0xa0);
while(status==1)
{
i2c_start();
status=i2c_write(0xa0);
}

Download the 24LC256 data sheet and read Section 7.0:
http://ww1.microchip.com/downloads/en/DeviceDoc/21203N.pdf
Joshua Lai



Joined: 19 Jul 2004
Posts: 42
Location: Malaysia, PJ

View user's profile Send private message Send e-mail

Fast eeprom reading
PostPosted: Tue Sep 20, 2005 7:37 pm     Reply with quote

I tried writing my own program to write and read eeprom, it is working !!

Quote:

#include <16F876.h>
#use delay(clock=20000000)
#use i2c(master,sda=PIN_C4,scl=PIN_C3)
#fuses hs,noprotect,nowdt,nolvp
#byte PORTB=6

int a, r;

main()
{
output_float(PIN_C3); //initialize eeprom
output_float(PIN_C4);

r=0;
set_tris_b(0);
portb=0x01; delay_ms(1000);
portb=0x00; delay_ms(1000);

i2c_start();
i2c_write(0xA0); //control write
i2c_write(0x00); //address (max 7FF8)
i2c_write(0x00);
i2c_write(0x01); //data (max page 64)
i2c_write(0x02);
i2c_write(0x04);
i2c_write(0x10);
i2c_write(0x20);
i2c_write(0x40);
i2c_write(0x80);
i2c_stop();
delay_ms(1000);

i2c_start();
i2c_write(0xA0);
i2c_write(0x00);
i2c_write(0x00);
i2c_start();
i2c_write(0xA1); //control read

for(a=0;a<8;a++)
{ r = i2c_read();
portb=r; delay_ms(1000);
}

portb=0x01; delay_ms(1000);
portb=0x00; delay_ms(1000);

}


What I actually need to do is abitrary waveform generation. I need to store and read large amount of data in the eeprom, where time accuracy (sampling rate) is very important, fast is important also. So I have to count how much time PIC spent to read the eeprom.

Instead of using the built in driver 24256, I write my own program to read the eeprom. I found that I save at least hundred lines of assembly code.

But I don't really understand the assembly code, does i2c_read() same as sequential read in the eeprom datasheet?

I can also read out the eeprom data using hyperterminal (through PIC). But how can I use hyperterminal to write the eeprom? Because my icprog 1.04 showing error when verifying the eeprom. Type in the data on hyperterminal one by one is too slow.
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