![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Joshua Lai
Joined: 19 Jul 2004 Posts: 42 Location: Malaysia, PJ
|
2465, 24128, 24256 why driver diff? |
Posted: Sat Sep 17, 2005 3:27 am |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 18, 2005 2:09 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Joshua Lai
Joined: 19 Jul 2004 Posts: 42 Location: Malaysia, PJ
|
|
Posted: Sun Sep 18, 2005 9:05 pm |
|
|
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);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
![](templates/subSilver/images/spacer.gif) |
Joshua Lai
Joined: 19 Jul 2004 Posts: 42 Location: Malaysia, PJ
|
Fast eeprom reading |
Posted: Tue Sep 20, 2005 7:37 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|