ESP32 I2C Timing Question

taxi_dong
Posts: 7
Joined: Mon Feb 06, 2017 3:29 am

ESP32 I2C Timing Question

Postby taxi_dong » Tue Apr 25, 2017 12:08 pm

Hi
I need read 32KB/Second from a I2C slave device, I catch follow I2C wave from scope during I2C reading by ESP32
bad.jpg
bad.jpg (859.5 KiB) Viewed 2585 times
Meanwhile I have an reference platform connecting the same I2C slave device, the wave is follow
good.jpg
good.jpg (775.36 KiB) Viewed 2585 times
The code base is esp-idf-v2.0, upgraded from esp-idf-v2.0-rc1. ESP32 HW is esp_wroom_32 module.
I2C Read Code repeat calling escore_i2c_read() , size is 4K

int escore_i2c_read(void *handle, uint8_t *rxBuffer, uint16_t size) {
if (size == 0) {
return ESP_OK;
}
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, ( ES817_SENSOR_ADDR << 1 ) | READ_BIT, ACK_CHECK_EN);
if (size > 1) {
i2c_master_read(cmd, rxBuffer, size - 1, ACK_VAL);
}
i2c_master_read_byte(cmd, rxBuffer + size - 1, NACK_VAL);
i2c_master_stop(cmd);
esp_err_t ret = i2c_master_cmd_begin(i2c_master_port, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);


if(handle != 0x1234){
char out[14] = {0};
size = size > 4 ? 4 : size;
HexToAscii(rxBuffer, size, out, 14);
ESP_LOGI(TAG, "I2C Bus read %s", out);
}

return ret;
}

I want to make ESP32 I2C read timing similar to the reference device == > regular sleep between every 8 bit data+ 1bit ACK.
Is there any suggestion?
Thanks

Who is online

Users browsing this forum: No registered users and 119 guests