hello team,
I’m trying to read the value from ADC121C021 but I am not able to get ack while writing the ADC buffer my code is here please let me know what is wrong with it
esp_err_t i2c_master_init(void){
xI2CBusy = xSemaphoreCreateMutex();
if(xI2CBusy == NULL)
{
ESP_LOGE(TAG, "Error in Creating Mutex: xI2CBusy");
}
int i2c_master_port = I2C_PORT_NO;
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = I2C_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = I2C_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = I2C_FREQ;
conf.clk_flags = 0;
i2c_param_config(i2c_master_port, &conf);
return i2c_driver_install(i2c_master_port, conf.mode,0, 0, 0);
}
esp_err_t read_ADS(i2c_port_t i2c_num, uint8_t *data_h, uint8_t *data_l){
int ret;
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, 0x50 | 0x00, 0x01); // Slave Write Add
i2c_master_write_byte(cmd, 0x02, 0x01); // Configuration Reg
i2c_master_write_byte(cmd, 0x20, 0x01); // Config Value
i2c_master_start(cmd);
i2c_master_write_byte(cmd, 0x50 | 0x01 , 0x01); // Slave Read Add
i2c_master_write_byte(cmd, 0x00, 0x01); // READ_BUFFER
i2c_master_read_byte(cmd, data_h, 0x00);
i2c_master_read_byte(cmd, data_l, 0x01);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(i2c_num, cmd, 1000 / portTICK_RATE_MS);
i2c_cmd_link_delete(cmd);
if (ret == ESP_ERR_TIMEOUT) {
printf( "I2C Timeout 2\n");
} else if (ret == ESP_OK) {
printf( "I2C Doing Good 2\n");
}else if (ret != ESP_OK) {
printf( "I2C not Working 2\n");
}
return ret;
}
by that code I’m getting only “I2C not working 2” … So help me out