This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] RTOS:AM3358对 I2C EEPROM 的读取/写入操作

Guru**** 2587365 points
Other Parts Discussed in Thread: AM3358

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/634428/rtos-am3358-read-write-operations-to-i2c-eeprom

主题中讨论的其他器件:AM3358

工具/软件:TI-RTOS

您好!

我尝试在我的定制 am3358板(phytec phycore AM335x)上使用 i2c 绑定的 EEPROM。 可通过 I2C ID 0x52对其进行访问、我想将配置数据存储在此 EEPROM 中。  

我使用以下代码运行 I2C 从任务读取:

char i2c_read (int RegAdd、int address、int channel)
{

uint8_t txBuffer[1]={RegAdd};
char rxBuffer[1]={0};
I2C_Handle 句柄;
如果(通道= 1)
{
句柄= i2c_chan1_init();
}
否则、如果(通道= 0)
{
句柄= i2c_chan0_init();
}
int16_t transferStatus;
I2C_Transaction i2cTransaction;
I2C_TransactionInit(&i2cTransaction);

i2cTransaction.slaveAddress =地址;
i2cTransaction.readBuf =(uint8_t *)&rxBuffer[0];
i2cTransaction.writeBuf =(uint8_t *)&txBuffer[0];
i2cTransaction.writeCount = 1;
i2cTransaction.ReadCount = 0;
i2cTransaction.timeout = 100;
transferStatus = I2C_transfer (handle、&i2cTransaction);
Task_sleep (100);
i2cTransaction.readBuf =(uint8_t *)&rxBuffer[0];
i2cTransaction.writeBuf =(uint8_t *)&txBuffer[0];
i2cTransaction.writeCount = 0;
i2cTransaction.ReadCount = 1;
i2cTransaction.timeout = 100;
transferStatus = I2C_transfer (handle、&i2cTransaction);
I2C_Close (handle);
返回 rxBuffer[0];
} 

写入函数遵循以下原理图:

int16_t i2c_write (char buf[5]、int address、int channel)
{
I2C_Handle 句柄;
如果(通道= 1)
{
句柄= i2c_chan1_init();
}
否则、如果(通道= 0)
{
句柄= i2c_chan0_init();
}
int16_t transferStatus;
I2C_Transaction i2cTransaction;
I2C_TransactionInit(&i2cTransaction);
i2cTransaction.slaveAddress =地址;
i2cTransaction.readBuf =空;
i2cTransaction.ReadCount = 0;
i2cTransaction.writeBuf =(uint8_t *)&buf[0];
i2cTransaction.writeCount = 2;
i2cTransaction.timeout = 2000;
transferStatus = I2C_transfer (handle、&i2cTransaction);
I2C_Close (handle);
返回传输状态;
} 

我的问题是写入和读取功能都没有成功执行、我找不到其他用于写入或读取 EEPROM 的示例。  

即使我尝试使用 i2cset 从 Yocto Linux 内对 EEPROM 进行编程、 我也不成功。 i2cdump 返回许多0xFF。

写入使能引脚通过 phycore SOM 上的10k Ω 电阻器拉至 GND。 我希望你能帮助我。

此致、

Jim

编辑:是否有任何现有驱动程序可将数据存储在非易失性存储器中,例如 SPI 或 Nand 闪存 ?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好!

    您是否正确地对 I2C 引脚进行了引脚多路复用? I2C 线路上是否有外部上拉电阻器?
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您好、Biser、

    是的、它们在 C16和 C17上进行引脚多路复用、并且都具有1、5k 外部上拉电阻(集成在 SoM 上)。

    此致、
    Jim
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    您是否在 I2C_SCL 引脚上启用了接收器?
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    是的、我已经使用 TI Pinmux 工具进行多路复用并检查了配置服务器时间。

    此致、
    Jim
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    这样就消除了硬件部分。 我已通知 RTOS 团队。 它们将从这里继续。
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    Jim、
    在 PSD 中有一个 I2C EEPROM 示例、位于 C:\ti\pdk_am335x_1_0_8\packages\MyExampleProjects\I2C_Example_evmAM335x_armExampleProject。
    你看了吗?

    Lali
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    Lali、您好、感谢您的回答。
    该问题位于 Code Composer 中、重新导入新工作区解决了该问题。

    Jim