Skip to main content
Sal-a.1
Associate
February 11, 2021
Solved

st board=spc582b .salve device=24c128. read data 0xff , so i can not able to write and read, my result is WRITEDATA=S,ADDRS=0X50,A,SUBADDR=0X20,A,0X55,A0X66,A,S. READ DATA=S,ADDRS=0X50,A,SUBADDR=0X20,A,0XFF,A,0XFF,N,S.

  • February 11, 2021
  • 2 replies
  • 1249 views

i have uploaded my main.c code.

    This topic has been closed for replies.
    Best answer by Sal-a.1

    thanks angelo,

    in solved due to this changes

    I2C_16_BIT_REG_ADDRESS changed before it is I2C_8_BIT_REG_ADDRESS

    i2c_result_t i2c_lld_write(I2CDriver *i2cd, uint8_t dev_addr, uint16_t reg_addr, uint8_t *data, uint8_t ndata_bytes) {

     if (ndata_bytes == 0U) {

      return I2C_NO_ERROR;

     }

     /* Check for valid address */

     if ((dev_addr == 0U) || ((dev_addr & 1U) == 1U)) {

      return I2C_ERROR_INVALID_ADDRESS;

     }

     if (data == NULL) {

      return I2C_ERROR_INVALID_ARGUMENT;

     }

     return (i2cd->ops.write != NULL) ? i2cd->ops.write(i2cd->ops.priv, dev_addr, reg_addr, I2C_16_BIT_REG_ADDRESS, data, ndata_bytes) : I2C_ERROR_INVALID_ARGUMENT;

    }

    2 replies

    Angelo Castello
    ST Employee
    February 12, 2021

    Good morning,

    Could you please tell me if the original demo is or not working fine into your environment ?

    Did you changed some configurations in term of I2C clock ?

    If you are using the SPC582B-DISP

    https://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-mpu-eval-tools/spc5-automotive-mcu-eval-tools/spc582b-dis.html

    and the expansion board based on VL6180X

    https://www.st.com/content/st_com/en/products/ecosystems/stm32-open-development-environment/stm32-nucleo-expansion-boards/stm32-ode-sense-hw/x-nucleo-6180xa1.html#documentation

    they are totally pin compatible and then you should run the demo as it is without problem. Please confirm to me.

    Let me know,

    Regards, Angelo

    Sal-a.1
    Sal-a.1AuthorBest answer
    Associate
    February 18, 2021

    thanks angelo,

    in solved due to this changes

    I2C_16_BIT_REG_ADDRESS changed before it is I2C_8_BIT_REG_ADDRESS

    i2c_result_t i2c_lld_write(I2CDriver *i2cd, uint8_t dev_addr, uint16_t reg_addr, uint8_t *data, uint8_t ndata_bytes) {

     if (ndata_bytes == 0U) {

      return I2C_NO_ERROR;

     }

     /* Check for valid address */

     if ((dev_addr == 0U) || ((dev_addr & 1U) == 1U)) {

      return I2C_ERROR_INVALID_ADDRESS;

     }

     if (data == NULL) {

      return I2C_ERROR_INVALID_ARGUMENT;

     }

     return (i2cd->ops.write != NULL) ? i2cd->ops.write(i2cd->ops.priv, dev_addr, reg_addr, I2C_16_BIT_REG_ADDRESS, data, ndata_bytes) : I2C_ERROR_INVALID_ARGUMENT;

    }