10 posts / 0 new
Last post
sjabir2004@yahoo.com
Offline
Last seen:5 years 3 months ago
Joined:2015-09-18 22:13
multiple byte read i2c

Hello,
My i2c 24bit ADC sensor requires the following:
1- slv-adrs-->command_start_conversion
2- slv-adrs-->read_byte1(master ACK read)-->Read_byte2(master ACK read)- Read_byte3(master-ACK read)

How can this be done ?

问题是,ADC发送冷杉t byte and gets know ACK from the 14580 so it stops sending.

发送地址+读取命令后,14580应在每个接收的字节后发送ACK。
The attached image shows how the sensor is acknowledging the receipt of the address and starts to send the first byte
and the DA14580 is not sending ACK at the end.

Keywords:
Attachment:
Device:
MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
Joined:2015-06-08 11:34
Hi sjabir2004,

Hi sjabir2004,

I suppose that you can achieve this functionallity with the allready exitsing i2c_eeprom_read_data() function. Just comment out the i2c_wait_until_eeprom_ready() and try to initilaize the eeprom with eeprom_init() then invoke the i2c_eeprom_read_data(data, address, num) and finally release the i2c. In the num parameter plave that you want your module to perform 3 read transactions and the da should ACK the first 2 bytes and NAK the third byte in order to finish the transaction.

Thanks MT_dialog

sjabir2004@yahoo.com
Offline
Last seen:5 years 3 months ago
Joined:2015-09-18 22:13
Hello,

Hello,

The function i2c_eeprom_read_data() will invoke read_data_single function. This function will send to the sensor , as many read signals as requested in the call BEFORE to start reading.
I do not see this functionality in my sensor. I see a stream of successive bytes sent from the sensor as in the attached document.

Here is the read_data_single function :

static void read_data_single(uint8_t **p, uint32_t address, uint32_t size)
{
int j;

i2c_send_address(address);

// this function sends successive reads while sensor needs one read only !!
for (j = 0; j < size; j++)
{
WAIT_WHILE_I2C_FIFO_IS_FULL(); // Wait if Tx FIFO is full
SEND_I2C_COMMAND(0x0100); // Set read access for times
}

// Critical section
GLOBAL_INT_DISABLE();

// Get the received data
for (j = 0; j < size; j++)
{
wait_for_received_byte();//等待收到的数据
**p =(0xFF & GetWord16(I2C_DATA_CMD_REG)); // Get the received byte
(*p)++;
}
// End of critical section
GLOBAL_INT_RESTORE();
}

Attachment:
MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
Joined:2015-06-08 11:34
Hi sjabir2004,

Hi sjabir2004,

You also directly use the read_data_single() function as long as you keep the bytes read under 32bytes. It isn't clear on your previous post though what is your problem since you state that your sensor gets the ack from the da and then stops sending and at the end of your post you say that the da doesn't send an ack at all.使用READ_DATA_SINGLE函数在I2C传感器上测试,我正确地获得了ACK字节。附加的图像是read_data_single()函数的函数,它具有相同的序列as your sensor requires.

Thanks MT_dialog

sjabir2004@yahoo.com
Offline
Last seen:5 years 3 months ago
Joined:2015-09-18 22:13
你好,

你好,

My Summary:
When I send a known command to the sensor , I get ACK from the sensor .
When I send read command to the sensor, the command is acknowledged by the sensor and the sensor starts to send three successive bytes. ( because it is 24bit)
The first byte is not Acknowledged by DA so it stops sending though I can see the sent data in the DATA_CMD_REG.

The question:
How does the DA know how many bytes to collect? (in your sent image , I noticed you wrote 3 to the sensor and collected three bytes)
When is the DA generating ACK? is it after each read byte from DATA_CMD_REG?

How does the DA14580 generate ACK?

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
Joined:2015-06-08 11:34
Hi sjabir2004,

Hi sjabir2004,

DA知道自从执行3读操作以来收集的字节数。在第一个循环中的read_data_single中,它发出大小(3)读命令,因此它需要3个字节,然后它访问FIFO以获取收到的字节。一旦主设备在他的缓冲区中获得一个字节,就应该发送ACK。

Thanks MT_dialog

sjabir2004@yahoo.com
Offline
Last seen:5 years 3 months ago
Joined:2015-09-18 22:13
Hello,

Hello,

这正是我所说的,在我发送的传感器的PDF中(这里再次连接),只有一个(地址+读取信号),那么来自DA的ACK的三个收集的字节。

The problem is that the first byte is in the buffer ( I do collect it) but there is no ACK from DA which stops the sensor transmission.

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
Joined:2015-06-08 11:34
Hi sjabir2004,

Hi sjabir2004,

在第一个交易之后,您获得了一个NACK,虽然您指示您的DA执行3个成功读取?Do you have a logic analyser trace to attach ?

Thanks MT_dialog

daniel7043
Offline
Last seen:3 years 8 months ago
Joined:2016-01-12 14:59
Hello,

Hello,

it seems that I have got a similar problem:
I want to read some bytes from an eeprom. How to get the data shows the picture in the attachment.
But as sjabir I have the problem that I can just receive the first byte, because my DA14580 sends a NACK, so the eeprom stops to sends the other bytes.
Here is my code:

GLOBAL_INT_DISABLE();
int a = 0;
uint8_t value[16] = {0};
i2c_eeprom_init(i2c_slave_address,i2c_speed_mode,i2c_address_mode,i2c_address_size);
SEND_I2C_COMMAND(02); //1. u 2.
WAIT_WHILE_I2C_FIFO_IS_FULL();
SEND_I2C_COMMAND(0x0100);

for(int i = 0;i<16;i++)
{
wait_for_received_byte();//等待收到的数据
value[i] =(0xFF & GetWord16(I2C_DATA_CMD_REG)); // Get the received byte
}
GLOBAL_INT_RESTORE();
}

它不会比wait_for_received_byte()更进一步(第一个字节发送后)。

I also attached the picture from my anaylizer.

I am grateful for any help!

Daniel

Attachment:
daniel7043
Offline
Last seen:3 years 8 months ago
Joined:2016-01-12 14:59
I found my own mistake...

I found my own mistake...
I changed the line

WAIT_WHILE_I2C_FIFO_IS_FULL();
SEND_I2C_COMMAND(0x0100);

to

for(int i = 0;i<16;i++)
{
WAIT_WHILE_I2C_FIFO_IS_FULL();
SEND_I2C_COMMAND(0x0100);
}

Topic locked