سلام دوستان
من از این برنامه برای eeprom 24C04 استفاده کردم مشکل اینجاست
که این برنامه برای eeprom 24C04 فقط 256 بایت رو مینویسه ومیخونه
در حالی که با همین برنامه میشه تمام حافظه یک eeprom 24C64 v رو
نوشت وخوند مشکل کجاست .
ممنون میشوم یه با دیگه کمکم کنید :redface:
#include <90s2313.h>
#include <delay.h>
#asm
.equ __i2c_port=0x12
.equ __sda_bit=6
.equ __scl_bit=5
#endasm
#include <i2c.h>
unsigned char eeprom_read(unsigned int address)
{
unsigned char data;
i2c_start();
i2c_write(160);
i2c_write((address & 0x1fff)>>8);
i2c_write(address & 0x1fff);
i2c_start();
i2c_write(161);
data=i2c_read(0);
i2c_stop();
return data;
}
void eeprom_write(unsigned int address, unsigned char data)
{
i2c_start();
i2c_write(160);
i2c_write((address & 0x1fff)>>8);
i2c_write(address & 0x1fff);
i2c_write(data);
i2c_stop();
delay_ms(10);
}
void main(void)
{
i2c_init();
DDRB=0xff;
eeprom_write(511,0x55)
PORTB=eeprom_read(511);
while (1);
}
من از این برنامه برای eeprom 24C04 استفاده کردم مشکل اینجاست
که این برنامه برای eeprom 24C04 فقط 256 بایت رو مینویسه ومیخونه
در حالی که با همین برنامه میشه تمام حافظه یک eeprom 24C64 v رو
نوشت وخوند مشکل کجاست .

ممنون میشوم یه با دیگه کمکم کنید :redface:
#include <90s2313.h>
#include <delay.h>
#asm
.equ __i2c_port=0x12
.equ __sda_bit=6
.equ __scl_bit=5
#endasm
#include <i2c.h>
unsigned char eeprom_read(unsigned int address)
{
unsigned char data;
i2c_start();
i2c_write(160);
i2c_write((address & 0x1fff)>>8);
i2c_write(address & 0x1fff);
i2c_start();
i2c_write(161);
data=i2c_read(0);
i2c_stop();
return data;
}
void eeprom_write(unsigned int address, unsigned char data)
{
i2c_start();
i2c_write(160);
i2c_write((address & 0x1fff)>>8);
i2c_write(address & 0x1fff);
i2c_write(data);
i2c_stop();
delay_ms(10);
}
void main(void)
{
i2c_init();
DDRB=0xff;
eeprom_write(511,0x55)
PORTB=eeprom_read(511);
while (1);
}
دیدگاه