| Author |
Message |
Analyzer
Joined: 18 Nov 2001 Posts: 414
|
23 Dec 2003 21:47 proteus show vterm |
|
|
|
|
Hi there,
I need more than 100 Kb memory for my application.I'm using ccs c compiler, 16F877, 24LC256 and proteus for desing.Can i use more than one I2C memory with same pins? I want to use 4 24LC256 on the same line (same pins of 877) Is it possible? If so, How can i use it? Any proteus dsn files for this? Or some brief will be fine for me
Thanks
Analyzer.
|
|
| Back to top |
|
 |
Ace-X
Joined: 25 Jan 2002 Posts: 590 Helped: 26
|
23 Dec 2003 22:23 i2c_write(address &0xfe) |
|
|
|
|
Usually, I2C chip has three additional pins: A2-A0. These pins represent the part of I2C devices address and being connected to 0 or 1 can be used to assign different addresses to different chips. So, that you can address these chips individually. Check 24LC256 datasheet if you need more info.
Ace-X.
|
|
| Back to top |
|
 |
Google AdSense

|
23 Dec 2003 22:23 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
tobb
Joined: 20 Sep 2002 Posts: 87 Helped: 1
|
24 Dec 2003 7:57 |
|
|
|
|
| usually every i2c device have there own address. i2c device are also have family pre-fix address bit and select address bit. example 24CXXX eerom memory will have address bit of 1010 and change able bit for chip select A2 A1 A2 , you could set this bit by connect these pin or memory ic to logic low or hi (Gnd or Vcc) and when you what to access to these chip you just ask for right address. For other device like port expander etc.. the family code will change it by the manufacture so it not mix up with the memory device. I think we may possible to use more than 10 device on one line. One thing you need to becare full of using a lot of device on one line is the pull up resister value of sda and scl . If you use a lot of device with a long distance you may need good pull up resister calculation or some circuit to help line transfer data and clock correctly. I have been build loger with 4 24lc256 and they are working fine...
|
|
| Back to top |
|
 |
ntfreak
Joined: 22 Feb 2002 Posts: 193 Helped: 5 Location: UK
|
24 Dec 2003 10:19 Re: More than 1 I2C on single line |
|
|
|
|
As that device has 3 address pins you will be ok for upto 8 devices on the I2C bus.
Just as a thought, have you not considered serial flash - much larger memory sizes are available (>1Mb).
Regards
sjo
|
|
| Back to top |
|
 |
ergen
Joined: 31 May 2002 Posts: 28
|
24 Dec 2003 20:41 Re: More than 1 I2C on single line |
|
|
|
|
So,
Should i connect devices like this? :
By the way i cannot login as "Analyzer" :
I change it to jpg and added a vterm.
Last edited by ergen on 24 Dec 2003 23:05; edited 1 time in total |
|
| Back to top |
|
 |
Ace-X
Joined: 25 Jan 2002 Posts: 590 Helped: 26
|
24 Dec 2003 21:19 Re: More than 1 I2C on single line |
|
|
|
|
[quote="ergen"]
Should i connect devices like this?
[quote]
Yes, it is right. Now your EEPROMs have addresses: 1010000 and 1010001.
Ace-X.
|
|
| Back to top |
|
 |
Analyzer
Joined: 18 Nov 2001 Posts: 414
|
24 Dec 2003 23:11 |
|
|
|
|
Hmm,
I'm very confused to use these addresses.I'm using CCS C Compiler 3.168 and Proteus 6 I tested this schematic with this code :
#include "c:\.....\I2C_Mem.h"
#include <24128.c>
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)
void main() {
int16 c,i,s;
init_ext_eeprom();
c = 1;i=50;
s=32000;
printf("WRITE\n\r");
while(c < 100) {WRITE_EXT_EEPROM(c+s,i);c++;i++;if (i>100) i=50;}
c = 1;i=50;
printf("READ\n\r");
while(c < 100) {printf("%c",READ_EXT_EEPROM(c+s));c++;i++;if (i>100) {i=50;printf("\n\r");}}
printf("\n\rFinished");
}
I missed something with addresses i think, and i have no idea how to talk with first and second memory.. This code works if 0<s<32676 So, i think i can not access to the second memory. I'm close to finish
Analyzer.
|
|
| Back to top |
|
 |
Ace-X
Joined: 25 Jan 2002 Posts: 590 Helped: 26
|
25 Dec 2003 10:49 |
|
|
|
|
| Analyzer wrote: |
| I'm very confused to use these addresses. |
I guess, you miss the difference between I2C device address and address inside EEPROM memory. I2C supports up to 128 devices on the same lines, so before you will send/receive any data from device, you have to select it. So, you send its address on I2C bus to show that the next command will be addressed to very this device. We use I2C address at this point (1010000 or 1010001 in your case). After that you send the command to I2C EEPROM on reading/writing from/to specified address. Here we are talking about address inside memory.
As to your case, I think you have to take a look for changes inside file 24128.c (not sure, 'cause I never worked with CCS).
Good luck and Merry Christmas!
Ace-X.
|
|
| Back to top |
|
 |
shawndaking
Joined: 20 Jun 2001 Posts: 235 Helped: 6
|
25 Dec 2003 18:59 Re: More than 1 I2C on single line |
|
|
|
|
| 470k for pull up is too low for i2c mabee 470 ohm or 4.7k but not 470 k !
|
|
| Back to top |
|
 |
Analyzer
Joined: 18 Nov 2001 Posts: 414
|
25 Dec 2003 19:36 |
|
|
|
|
#include <24128.c>
#ifndef EEPROM_SDA
#define EEPROM_SDA PIN_B1
#define EEPROM_SCL PIN_B0
#endif
#define hi(x) (*(&x+1))
#use i2c(master, sda=EEPROM_SDA, scl=EEPROM_SCL)
#define EEPROM_ADDRESS long int
#define EEPROM_SIZE 16384
void init_ext_eeprom()
{
int i;
output_float(EEPROM_SCL);
output_float(EEPROM_SDA);
delay_us(4);
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();
}
}
void write_ext_eeprom(long int address, BYTE data)
{
i2c_start();
i2c_write(((0xa0)|(hi(address)>>5))&0xfe);
i2c_write(hi(address)&0x3f);
i2c_write(address);
i2c_write(data);
i2c_stop();
delay_ms(10);
}
BYTE read_ext_eeprom(long int address) {
BYTE data;
i2c_start();
i2c_write(((0xa0)|(hi(address)>>5))&0xfe);
i2c_write(hi(address)&0x3f);
i2c_write(address);
i2c_start();
i2c_write((0xa1)|(hi(address)>>5));
data=i2c_read(0);
i2c_stop();
return(data);
}
This is the header driver file i am using.Here is i2cwrite prototype :
i2c_start(); // Start condition
i2c_write(0xa0);// Device address
i2c_write(cmd);// Low byte of command
i2c_write(cmd>> 8 );// High byte of command
i2c_stop(); // Stop condition
I need to change first i2write to choose rigth address.Am i right? :
void write_ext_eeprom(long int address, BYTE data)
{
i2c_start();
i2c_write(((0xa0)|(hi(address)>>5))&0xfe); //This line to be changed
i2c_write(hi(address)&0x3f);
i2c_write(address);
i2c_write(data);
i2c_stop();
delay_ms(10);
}
I need to rewrite write_ext_eeprom(...) and read_ext_eeprom(...). How should i change my header file?
Analyzer
|
|
| Back to top |
|
 |