I'd like to confirm the behaviour of i2c on esp32-s3
Posted: Sat Feb 03, 2024 3:38 pm
Hi,
I have 2 ESP devices communicating together with i2c.
The master is a ESP32
Slave is a esp32-s3 with address 0x28
The master periodically issues a read to get 4 bytes from the slave. When there is no data in the queue of the slave (the s3), I get the following:
51h would be (28h << 1) | 1. So that makes sense.
But why does the slave respond back with ?
I would expect either:
-
- Or
Is the behaviour I am seeing normal? Is this expected or does this mean I either have an issue in my code or with the wiring. Or maybe it's an issue with the S3?
FWIW, this is the code I'm using on the master:
I have 2 ESP devices communicating together with i2c.
The master is a ESP32
Slave is a esp32-s3 with address 0x28
The master periodically issues a read to get 4 bytes from the slave. When there is no data in the queue of the slave (the s3), I get the following:
Code: Select all
START, 51h, ACK, 51h, ACK, FFh, ACK, FFh, ACK, FFh, NACK, STOP
But why does the slave respond back with
Code: Select all
51h,FFh,FFh,FFh
I would expect either:
-
Code: Select all
START, 51h, NACK
- Or
Code: Select all
START, 51h, ACK, FFh, ACK, FFh, ACK, FFh, ACK, FFh, NACK, STOP
FWIW, this is the code I'm using on the master:
Code: Select all
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (0x28 << 1) | 1, ACK_CHECK_EN);
i2c_master_read_byte(cmd, data_rd, (i2c_ack_type_t)ACK_VAL);
i2c_master_read_byte(cmd, data_rd + 1, (i2c_ack_type_t)ACK_VAL);
i2c_master_read_byte(cmd, data_rd + 2, (i2c_ack_type_t)ACK_VAL);
i2c_master_read_byte(cmd, data_rd + 3, (i2c_ack_type_t)I2C_MASTER_LAST_NACK);
i2c_master_stop(cmd);
esp_err_t ret = i2c_master_cmd_begin(i2c_num, cmd, 10);
i2c_cmd_link_delete(cmd);