Linduino icon indicating copy to clipboard operation
Linduino copied to clipboard

not able to read adc2497

Open fenilGhoghari opened this issue 1 year ago • 1 comments

Hello,

I am trying to read LTC2497 with my esp32 with esp-idf framework but most of time it miss the acknowledgement can you suggest the code.

I have write below code for read function:

int8_t i2c_read_block_data(uint8_t address, uint8_t command, uint8_t length, uint8_t *values)
{
    uint8_t i = (length - 1);
    int8_t ret = 0;

    i2c_cmd_handle_t cmd = i2c_cmd_link_create();

    i2c_master_start(cmd);
    i2c_master_write_byte(cmd, address << 1 | I2C_MASTER_WRITE, true);
    i2c_master_write_byte(cmd, command, true);
    i2c_master_stop(cmd);
    vTaskDelay(100 / portTICK_PERIOD_MS);
    esp_err_t err = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_PERIOD_MS);
    i2c_cmd_link_delete(cmd);

    if (err != ESP_OK)
    {
        printf("Fail to begin 1 \n");
        return (1);
    }
    vTaskDelay(100 / portTICK_PERIOD_MS);

    cmd = i2c_cmd_link_create();    
    i2c_master_start(cmd);
    i2c_master_write_byte(cmd, address << 1 | I2C_MASTER_READ, true);
    i2c_master_read(cmd, values, length, I2C_MASTER_ACK);
    i2c_master_stop(cmd);
    vTaskDelay(100 / portTICK_PERIOD_MS);
    err = i2c_master_cmd_begin(I2C_NUM_0, cmd, 1000 / portTICK_PERIOD_MS);
    i2c_cmd_link_delete(cmd);

    if (err != ESP_OK)
    {
        printf("Fail to begin 2 \n");
        return (1);
    }

    return (0); // Successful
}

above function i have written in LT_I2C_Wire.c can you please suggest the solution.

controller: ESP32S3 Framework: ESP-IDF Supply: 3.3 V Connection : I2C (SDA, SCL) REF+ : 3.3 V REF- : GND Address: 0x14 [CA0 , CA1 , CA 2 = LOW ] COM : GND

i am trying to read in CH0 address 0xB0

Thanks, Fenil

fenilGhoghari avatar May 13 '23 11:05 fenilGhoghari

Hello @gudnimg

Can you please suggest?

Thanks, Fenil

fenilGhoghari avatar May 13 '23 11:05 fenilGhoghari