I2C Timeout. I2C hardware stops after one transition.
Posted: Tue Oct 08, 2019 5:51 pm
Ive been trying to the the I2C to work on my Hiletgo ESP-WROOM module. Im using pin 22 for SCL, and 21 for SDA. This is also using freertos. One task blinks an LED, and the other is trying to write a byte. This is only test code and not meant to be complete. Some code to init the I2C:
And fails with a timeout (ret - ESP_ERR_TIMEOUT) in this code:
This is what Im seeing. While I know the above write code is not complete, it should at least send out enough clocks to get a ACK/NACK. I've used I2C plenty of times in the past, but not with the ESp32. Please see attached image.
Code: Select all
int i2c_master_port = i2c_num;
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = gpio_sda;
conf.sda_pullup_en = 0;
conf.scl_io_num = gpio_scl;
conf.scl_pullup_en = 0;
ESP_ERROR_CHECK(i2c_param_config(i2c_master_port, &conf));
ESP_ERROR_CHECK(i2c_driver_install(i2c_master_port, conf.mode,
I2C_RX_BUF_DISABLE, I2C_TX_BUF_DISABLE, 0));
Code: Select all
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, periph_address << 1 | WRITE_BIT, ACK_CHECK_EN);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);