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

twi fail in second msg attempt

hello

i am using nrf52832, with ble (s132 softdevice), pwm drv, saadc drcm uart, and using app_timers

i have added the twi drv to work with an expander for start.

this is how my function looks like

void i2c_transmit(uint8_t address, uint8_t * data)
{
    ret_code_t err_code = nrf_drv_twi_tx(&m_twi, address, data, sizeof(data), true);
    APP_ERROR_CHECK(err_code);
}

this is where i call the function:

uint8_t ex_config_reg_init_val = EXPANDER_CONFIG_PIN_AS_OUTPUT_MASK;

//configur expander pins as output via configure register
i2c_transmit(EXPANDER_CONFIGURATION_REGISTER_ADDRESS, &ex_config_reg_init_val);
// if send was success -> 
i2c_transmit(EXPANDER_OUTPUT_PORT_REGISTER_ADDRESS, &expander_data_byte);

first message gets ok, second fails (error 17) ->  [is there some file that shows what every error number is refering to ??? i could not find ]

this is my init:

void i2c_init(void)
{
   ret_code_t err_code;

    const nrf_drv_twi_config_t twi_config = {
       .scl                = ARDUINO_SCL_PIN,
       .sda                = ARDUINO_SDA_PIN,
       .frequency          = NRF_DRV_TWI_FREQ_100K,
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

    err_code = nrf_drv_twi_init(&m_twi, &twi_config, twi_handler, NULL);
    APP_ERROR_CHECK(err_code);

    nrf_drv_twi_enable(&m_twi);
}

i have read in this forom that i should config some event handler in my init but it is not clear to me what should be done in this event handler because i have nointtention to creat some loop that waits for some 'OK' event

also, when i run in debug mode i see that i am not entering the event handler at all so it is not so clear to me what i am doing wrong ???

how can i solve this ?

Best regards

Ziv

Parents Reply Children
No Data
Related