10个帖子/ 0新
最后一篇
sjabir2004@yahoo.com.
离线
最后一次露面:5年3个月前
加入:2015-09-18 22:13
多字节读取I2C

你好,
我的I2C 24bit ADC传感器需要以下内容:
1- SLV-ADRS - > COMMAND_START_CONVERSION
2-SLV-ADRS - > READ_BYTE1(主ACK READ) - > READ_BYTE2(主ACK READ) - READ_BYTE3(MASTER-ACK READ)

如何才能做到这一点 ?

问题是ADC发送第一个字节并从14580获取知道ACK,以便停止发送。

After sending address+read command , The 14580 should send an ACK after each received byte.
附加的图像显示了传感器如何确认接收地址并开始发送第一个字节
并且DA14580在最后没有发送ACK。

关键词:
附件:
设备:
mt_dialog.
离线
最后一次露面:2个月3周前
职员
加入:2015-06-08 11:34
嗨sjabir2004,

嗨sjabir2004,

我想你可以通过AllReady退出I2C_EEPROM_READ_DATA()函数来实现此功能。只需注释出I2C_WAIT_UNTIL_EEPROM_READY()并尝试使用EEPROM_INIT()启动EEPROM,然后调用I2C_EEPROM_READ_DATA(数据,地址,NUM)并最终释放I2C。在Num参数中,您希望模块执行3个读取事务,并且DA应该将前2个字节和Nak第三个字节进行完成,以完成事务。

谢谢mt_dialog.

sjabir2004@yahoo.com.
离线
最后一次露面:5年3个月前
加入:2015-09-18 22:13
你好,

你好,

函数i2c_eeprom_read_data()将调用read_data_single函数。此功能将发送到传感器,如前呼叫中的许多读取信号开始阅读。
我在传感器中没有看到此功能。我看到一个从传感器发送的连续字节的流,如附加文档中的。

这是read_data_single函数:

静态void read_data_single(uint8_t ** p,uint32_t地址,uint32_t大小)
{
in j;

i2c_send_address(地址);

//此功能在传感器只需要一张阅读时发送连续读数!!
for(j = 0; j {
等待_while_i2c_fifo_is_full();//等待TX FIFO已满
send_i2c_command(0x0100);//设置次次读取访问
}

//关键部分
global_int_disable();

//获取收到的数据
for(j = 0; j {
WAIT_FOR_RECEIVED_BYTE(); // Wait for received data
** p =(0xff&getword16(i2c_data_cmd_reg));//获取收到的字节
(* p)++;
}
//关键部分结束
global_int_restore();
}

mt_dialog.
离线
最后一次露面:2个月3周前
职员
加入:2015-06-08 11:34
嗨sjabir2004,

嗨sjabir2004,

只要您在32bytes下保持读取的字节,您也直接使用read_data_single()函数。您之前的帖子上并不清楚您的问题,因为您所说的传感器从DA中获取ACK,然后停止发送和在帖子的末尾,您可以说DA根本不会发送ACK。I ve tested on a i2c sensor with the read_data_single function and i get the ack bytes properly. The attached image is the function of the read_data_single() function and it has the same sequence随着传感器所需的。

谢谢mt_dialog.

sjabir2004@yahoo.com.
离线
最后一次露面:5年3个月前
加入:2015-09-18 22:13
你好 ,

你好 ,

我的摘要:
当我向传感器发送已知命令时,我将来自传感器的ACK。
当我向传感器发送读命令时,传感器确认命令,传感器开始发送三个连续字节。(因为它是24位)
第一个字节不由DA确认,因此它停止发送,但是我可以在data_cmd_reg中看到已发送的数据。

问题:
DA如何知道收集多少个字节?(在您发送的图像中,我注意到您将3写入传感器并收集三个字节)
什么时候是da生成ack?来自data_cmd_reg的每个读字节是它?

DA14580如何生成ACK?

mt_dialog.
离线
最后一次露面:2个月3周前
职员
加入:2015-06-08 11:34
嗨sjabir2004,

嗨sjabir2004,

The da know how many bytes to collect since it performs 3 read operations. In the read_data_single in the first for loop it issues size (3) read commands so it expects 3 bytes and then it accesses the FIFO to take the bytes received. The ACK should be sent as soon as the master gets a byte in his buffer.

谢谢mt_dialog.

sjabir2004@yahoo.com.
离线
最后一次露面:5年3个月前
加入:2015-09-18 22:13
你好,

你好,

这正是我说的,在t的pdfhe sensor I sent ( here attached again) , there is ONLY ONE (address+read signal) then three collected byte with ACK from DA.

问题是第一个字节是在缓冲区中(我收集它),但是没有来自DA的ACK,阻止传感器传输。

mt_dialog.
离线
最后一次露面:2个月3周前
职员
加入:2015-06-08 11:34
嗨sjabir2004,

嗨sjabir2004,

After the first transaction you get a NACK although you are instructing your da to perform 3 succesive reads ?您是否有逻辑分析仪跟踪要附加?

谢谢mt_dialog.

Daniel7043.
离线
最后一次露面:3年8个月前
加入:2016-01-12 14:59
你好,

你好,

看来我有一个类似的问题:
我想从EEPROM阅读一些字节。如何获取数据显示附件中的图片。
但正如Sjabir所在的问题,我可以收到第一个字节,因为我的da14580发出一个nack,所以EEPROM停止发送另一个字节。
这是我的代码:

global_int_disable();
int a = 0;
UINT8_T值[16] = {0};
i2c_eeprom_init(I2C_SLAVE_ADDRESS, I2C_SPEED_MODE, I2C_ADDRESS_MODE, I2C_ADDRESS_SIZE);
send_i2c_command(02);// 1。你2。
等待_while_i2c_fifo_is_full();
send_i2c_command(0x0100);

for(int i = 0; i <16; i ++)
{
WAIT_FOR_RECEIVED_BYTE(); // Wait for received data
值[i] =(0xff&getword16(i2c_data_cmd_reg));//获取收到的字节
}
global_int_restore();
}

It wont go further than WAIT_FOR_RECEIVED_BYTE() (after the first byte was send).

我也从我的Aaylizer附上了照片。

我很感激任何帮助!

丹尼尔

附件:
Daniel7043.
离线
最后一次露面:3年8个月前
加入:2016-01-12 14:59
我找到了自己的错误......

我找到了自己的错误......
我改变了这条线

等待_while_i2c_fifo_is_full();
send_i2c_command(0x0100);

for(int i = 0; i <16; i ++)
{
等待_while_i2c_fifo_is_full();
send_i2c_command(0x0100);
}

主题锁定