Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not able to read adc2497 #74

Open
fenilGhoghari opened this issue May 13, 2023 · 1 comment
Open

not able to read adc2497 #74

fenilGhoghari opened this issue May 13, 2023 · 1 comment

Comments

@fenilGhoghari
Copy link

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
Copy link
Author

Hello @gudnimg

Can you please suggest?

Thanks,
Fenil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant