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

MAX32670 I2C Driver causes a Double-Read #1293

Open
Brandon-Hurst opened this issue Dec 12, 2024 · 1 comment
Open

MAX32670 I2C Driver causes a Double-Read #1293

Brandon-Hurst opened this issue Dec 12, 2024 · 1 comment

Comments

@Brandon-Hurst
Copy link
Contributor

Brandon-Hurst commented Dec 12, 2024

Reading from a peripheral, it appears that the I2C driver for MAX32670 causes a double read.

What I Did

Connect an ADXL345 to I2C1 on MAX32670 EVKit. I am running the I2C example, and simply added the below source code before the main test runs...

    // FIXME: For testing
    uint8_t my_adxl_tx[1] = {0x0}; // ADXL ID Register
    uint8_t my_adxl_rx[2] = {0x0};
    mxc_i2c_req_t reqMaster = {
        .i2c = I2C_MASTER,
        .addr = 0x1D, // ADXL345 I2C Addr
        .tx_buf = my_adxl_tx,
        .rx_buf = my_adxl_rx,
        .tx_len = 1,
        .rx_len = 1,
        .callback = NULL,
    };
    I2C_FLAG=1;
    MXC_I2C_MasterTransaction(&reqMaster);

Outcome

Double read of ID Register

The above shows a repeated start and a double read of the register despite only attempting to read once.

I am trying to use MAX32670 with a No-OS Project using ADXL345 that I built. I have actually seen this condition cause infinite loops where the I2C bus sends out clocks forever and waits for data that will not come.

This happens because the i2c_reva.c MasterTransaction function erroneously sets the Restart bit and attempt to read again, when no more data will come back from the peripheral. It looks like an attempt was made to address this in commit #1211 but it may have been put off until further notice.

@Brandon-Hurst
Copy link
Contributor Author

May be related to #1211. It looks like the behavior I'm seeing is similar.

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