This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NR52832 I2C problem

Hi ,

I evaluate the I2c communication of your chip nrf52832. I have few problem.

  1. Write fonction

Is use your Tx fonction,

uint8_t reg[2] = {CCS811_REG_MODE, NORMAL_MODE};
err_code = nrf_drv_twi_tx(&m_twi, CCS811_ADDR, reg, sizeof(reg), false);

Whatever the configuration I can not manage the stop at the end of frameI2cNoStop.png.

  1. Write, restart and Read fonction.

Is use your Tx fonction and your RX fonction,

uint8_t reg[1] = {CCS811_REG_MODE};
err_code = nrf_drv_twi_tx(&m_twi, CCS811_ADDR, reg, sizeof(reg), false);
err_code = nrf_drv_twi_rx(&m_twi, CCS811_ADDR, &sample_data, sizeof(sample_data));

RestartAndReadI2c.png

I join my main.main.c

Can you help me to customize the i2c frames. Do you have other examples?

Thanks by advance Best Regards Guillaume

Parents
  • In your main.c file you configure the TWI in non-blocking mode. You need to wait for the first tx to complete and for the event handler to be called before you start the rx. In your code there is a flag called m_xfer_done, that is set to true in the twi_handler. You can use this flag by setting it to false before you start each TWI transfer and then wait for it to be set to true again before you start the next transfer.

    It is also always good practice to check the return codes in your code with APP_ERROR_CHECK(err_code);

Reply
  • In your main.c file you configure the TWI in non-blocking mode. You need to wait for the first tx to complete and for the event handler to be called before you start the rx. In your code there is a flag called m_xfer_done, that is set to true in the twi_handler. You can use this flag by setting it to false before you start each TWI transfer and then wait for it to be set to true again before you start the next transfer.

    It is also always good practice to check the return codes in your code with APP_ERROR_CHECK(err_code);

Children
Related