Hi,
I am developping a non blocking TWI (I2C) communication, calling this function:
static void charger_disable_low_power_mode_not_blocking(void) { const uint8_t frame_lsb[] = {0x00, 0x60}; const uint8_t frame_msb[] = {0x01, 0x0E}; const uint8_t frame[3] = {0x00, 0x60, 0x0E}; // Transfer type m_hal_drv_charger.xfer.twi_xfer.type = NRF_DRV_TWI_XFER_TX; // Length m_hal_drv_charger.xfer.twi_xfer.primary_length = 3; // Copy the frame pointer m_hal_drv_charger.xfer.twi_xfer.p_primary_buf = &frame[0]; // Add i2c xfer result = nrf_drv_twi_xfer(&i2c_twi, &m_hal_drv_charger.xfer.twi_xfer., 0);//NRF_DRV_TWI_FLAG_NO_XFER_EVT_HANDLER }
The init function of the twi is :
void hal_drv_charger_init_not_blocking(void) { ret_code_t err_code = nrf_drv_twi_init(&i2c_twi, &i2c_twi_config, twi_event_handler, NULL);//twi_event_handler // Configures the I2C transfer to send the charger frame at the charger address m_hal_drv_charger.xfer.twi_xfer.type = NRF_DRV_TWI_XFER_TX; m_hal_drv_charger.xfer.twi_xfer.address = HAL_DRV_CHARGER_ADDRESS; m_hal_drv_charger.xfer.twi_xfer.secondary_length = HAL_DRV_CHARGER_SEC_FRAME_SIZE; m_hal_drv_charger.xfer.callback = NULL; //Wait so the charger has correctly boot nrf_delay_ms(CHARGER_BOOT_TIME_MS);//Empirical value, to be determined if really useful by testing/reading datasheet/ //asking forum }
Please note that the real code is splitted in more functions, I concatenated it here for better understand, I might have forgotten something obvious, but the main point is that it works well without debugger, so I don't think the code is the issue.
The twi_event_handler is empty to be sure it doesn't create any mess.
As said, it works well in normal mode, but as soon as I go in debug mode, the maximum sent frames size is 1, even if the size is bigger (typically 3), and only sending the other ones after I run the next breakpoint that is not supposed to block the transmission at all.