共3条
1/1 1 跳转至页
i2c,AT24C01,eeprom,eeprom 模拟i2c外接AT24C01 eeprom,如何知道eeprom器件地址

问
#define EEPROM_BUS_ADDRESS 0xa0
请问怎么知道对某一片EEPROM_BUS_ADDRESS是多少 答 1: 1010xxxxxx是多少你自己在电路中设。
也就是接高或接地. 答 2: 是否把3个nc脚接地,那地址就是1010000是否把3个nc脚接地,那地址就是1010000,如果把这3个脚悬空,那地址就是1010111吗 答 3: 对啊,最后一位是读写位。是把A0A1A2接地。 答 4: 大家帮我看看以下程序,为何不可#include <mega128.h>
// I2C Bus functions
#asm
.equ __i2c_port=0x12
.equ __sda_bit=1
.equ __scl_bit=0
#endasm
#include <i2c.h>
#include <delay.h>
#include <stdio.h>
#define EEPROM_BUS_ADDRESS 0x0ae
/* 从EEPROM 读一个字节 */
unsigned char eeprom_read(unsigned char address) {
unsigned char data;
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS);
i2c_write(address);
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS | 1);
data=i2c_read(0);
i2c_stop();
return data;
}
/* 向EEPROM 写一个字节 */
void eeprom_write(unsigned char address, unsigned char data) {
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS);
i2c_write(address);
i2c_write(data);
i2c_stop();
/* 10 延时等待写操作完成 */
delay_ms(10);
}
main()
{
/* 初始化I2C 总 线 */
i2c_init();
/* 从地址0到127 写入55h */
for(j=0;j<128;j++)
eeprom_write(j,0x55);
/* 从地址AAh 读一个字节 */
for(j=0;j<128;j++)
Read_EEPROM[j] = eeprom_read(j);
for(j=0;j<128;j++)
putchar(Read_EEPROM[j]);
while(1);
} 答 5: EEPROM_BUS_ADDRESS 0x0ae 不对 答 6: 见// *********************************************************************** //
// *** H_ADD is the hardware address set on the device A0,A1 & A2 pins *** //
// *** M_ADD is the devices internal memory address *** //
// *** Data is user data to be writen *** //
// *********************************************************************** //
char EEPROM_Write(unsigned char H_ADD, unsigned int M_ADD, unsigned char * _Data,unsigned char len)
{
char i;
I2C_Start(); // Set I2C start condition
Write_I2C_Control(0x0A,H_ADD,0); // Send the EEPROM control Byte
Write_I2C_Byte(*(((char *)&M_ADD)+1)); // Send the EEPROM internal Address
Write_I2C_Byte(*((char *)&M_ADD)); // Send the EEPROM internal Address
for(i=0;i<len;i++)
Write_I2C_Byte( *(_Data+i)); // Send the EEPROM Data
I2C_Stop(); // Set I2C Stop condition
}
// *********************************************************************** //
// *** H_ADD is the hardware address set on the device A0,A1 & A2 pins *** //
// *** M_ADD is the devices internal memory address *** //
// *** Data is user data to be writen *** //
// *********************************************************************** //
unsigned char EEPROM_Read(unsigned char H_ADD, unsigned int M_ADD)
{
unsigned char Temp; // Temp RAM for EEPROM Read
I2C_Start(); // Set I2C start condition
Write_I2C_Control(0x0A,H_ADD,0); // Send the EEPROM control Byte
// Dummy write to set address
Write_I2C_Byte(*(((char *)&M_ADD)+1)); // Send the EEPROM internal Address
Write_I2C_Byte(*((char *)&M_ADD)); // Send the EEPROM internal Address
I2C_Start(); // Set I2C start condition
Write_I2C_Control(0x0A,H_ADD,1); // Send the EEPROM control Byte
Temp = Read_I2C_Byte(); // Read data from EEPROM
I2C_Stop(); // Set I2C Stop condition
return Temp; // Return data from EEPROM
}
答 7: 是否是因为频率原因请问你这个函数Write_I2C_Control(0x0A,H_ADD,0); // Send the EEPROM control Byte
是自己写的吗?如果采用14M的晶体振荡器,会不会就写不进去。
我以上程序是调用cvAVR的库函数,内部库函数数是不是只在一定的频率下才有效果 答 8: eeprom 为400k
请问怎么知道对某一片EEPROM_BUS_ADDRESS是多少 答 1: 1010xxxxxx是多少你自己在电路中设。
也就是接高或接地. 答 2: 是否把3个nc脚接地,那地址就是1010000是否把3个nc脚接地,那地址就是1010000,如果把这3个脚悬空,那地址就是1010111吗 答 3: 对啊,最后一位是读写位。是把A0A1A2接地。 答 4: 大家帮我看看以下程序,为何不可#include <mega128.h>
// I2C Bus functions
#asm
.equ __i2c_port=0x12
.equ __sda_bit=1
.equ __scl_bit=0
#endasm
#include <i2c.h>
#include <delay.h>
#include <stdio.h>
#define EEPROM_BUS_ADDRESS 0x0ae
/* 从EEPROM 读一个字节 */
unsigned char eeprom_read(unsigned char address) {
unsigned char data;
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS);
i2c_write(address);
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS | 1);
data=i2c_read(0);
i2c_stop();
return data;
}
/* 向EEPROM 写一个字节 */
void eeprom_write(unsigned char address, unsigned char data) {
i2c_start();
i2c_write(EEPROM_BUS_ADDRESS);
i2c_write(address);
i2c_write(data);
i2c_stop();
/* 10 延时等待写操作完成 */
delay_ms(10);
}
main()
{
/* 初始化I2C 总 线 */
i2c_init();
/* 从地址0到127 写入55h */
for(j=0;j<128;j++)
eeprom_write(j,0x55);
/* 从地址AAh 读一个字节 */
for(j=0;j<128;j++)
Read_EEPROM[j] = eeprom_read(j);
for(j=0;j<128;j++)
putchar(Read_EEPROM[j]);
while(1);
} 答 5: EEPROM_BUS_ADDRESS 0x0ae 不对 答 6: 见// *********************************************************************** //
// *** H_ADD is the hardware address set on the device A0,A1 & A2 pins *** //
// *** M_ADD is the devices internal memory address *** //
// *** Data is user data to be writen *** //
// *********************************************************************** //
char EEPROM_Write(unsigned char H_ADD, unsigned int M_ADD, unsigned char * _Data,unsigned char len)
{
char i;
I2C_Start(); // Set I2C start condition
Write_I2C_Control(0x0A,H_ADD,0); // Send the EEPROM control Byte
Write_I2C_Byte(*(((char *)&M_ADD)+1)); // Send the EEPROM internal Address
Write_I2C_Byte(*((char *)&M_ADD)); // Send the EEPROM internal Address
for(i=0;i<len;i++)
Write_I2C_Byte( *(_Data+i)); // Send the EEPROM Data
I2C_Stop(); // Set I2C Stop condition
}
// *********************************************************************** //
// *** H_ADD is the hardware address set on the device A0,A1 & A2 pins *** //
// *** M_ADD is the devices internal memory address *** //
// *** Data is user data to be writen *** //
// *********************************************************************** //
unsigned char EEPROM_Read(unsigned char H_ADD, unsigned int M_ADD)
{
unsigned char Temp; // Temp RAM for EEPROM Read
I2C_Start(); // Set I2C start condition
Write_I2C_Control(0x0A,H_ADD,0); // Send the EEPROM control Byte
// Dummy write to set address
Write_I2C_Byte(*(((char *)&M_ADD)+1)); // Send the EEPROM internal Address
Write_I2C_Byte(*((char *)&M_ADD)); // Send the EEPROM internal Address
I2C_Start(); // Set I2C start condition
Write_I2C_Control(0x0A,H_ADD,1); // Send the EEPROM control Byte
Temp = Read_I2C_Byte(); // Read data from EEPROM
I2C_Stop(); // Set I2C Stop condition
return Temp; // Return data from EEPROM
}
答 7: 是否是因为频率原因请问你这个函数Write_I2C_Control(0x0A,H_ADD,0); // Send the EEPROM control Byte
是自己写的吗?如果采用14M的晶体振荡器,会不会就写不进去。
我以上程序是调用cvAVR的库函数,内部库函数数是不是只在一定的频率下才有效果 答 8: eeprom 为400k
共3条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【EEPW电子工程师创研计划】技术变现通道已开启~ | |
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
分享汽车通信和多媒体总线结构被打赏20分 | |
【我踩过的那些坑】结构堵孔导致的喇叭无声问题被打赏50分 | |
NUCLEO-U083RC学习历程38+串口通过队列的方式输出两个字符串被打赏20分 | |
【我踩过的那些坑】分享一下调试一款AD芯片的遇到的“坑”被打赏50分 | |
电流检测模块MAX4080S被打赏10分 | |
【我踩过的那些坑】calloc和malloc错误使用导致跑飞问题排查被打赏50分 | |
分享电控悬架的结构与工作原理(一)被打赏20分 | |
多组DCTODC电源方案被打赏50分 | |
【我踩过的那些坑】STM32cubeMX软件的使用过程中的“坑”被打赏50分 | |
新手必看!C语言精华知识:表驱动法被打赏50分 |