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

I2C can't transfer more than 2 bytes

Hi,

I am using "TWI Sensor" example(SDK v17.0.2) as reference in our application. For multiple bytes transmission this is how I defined in "nrf_drv_twi_tx".

    ret_code_t err_code;

    /* Writing to LM75B_REG_CONF "0" set temperature sensor in NORMAL mode. */
    uint8_t reg[] = {'H', 'E', 'L', 'L', 'O'};
    err_code = nrf_drv_twi_tx(&m_twi, ARDUINO_CHIP_ID, reg, sizeof(reg), false);
    APP_ERROR_CHECK(err_code);
    while (m_xfer_done == false);

Here is how the output data on the protocol analyser, first transaction contains all 5-bytes but the remaining transaction contains only the first two bytes.

Am I missing something here? Any suggestions would be great.

Regards

Siva

Parents Reply Children
  • Hi awneil,

    This is my main, I just managed to resolve the issue after I posted here.

    int main(void)
    {
        APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
        NRF_LOG_DEFAULT_BACKENDS_INIT();
    
        NRF_LOG_INFO("\r\nTWI sensor example started.");
        NRF_LOG_FLUSH();
        twi_init();
        
        read_chip_ID();
            
        while (true)
        {
            nrf_delay_ms(500);
    
            do
            {
                __WFE();
            }while (m_xfer_done == false);
    
            //read_sensor_data();
            read_chip_ID();
            NRF_LOG_FLUSH();
        }
    }
    

    Solution is I need to comment out "NRF_LOG_FLUSH();" in the while loop after "read_chip_ID();".

    Regards

    Siva

Related