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

Calling nrf_drv_twi_init with a NULL context gives a app_error_fault_handler

I created a TWI software module which runs well as standalone. Now I need to put together with BLE code to comunicate with Android APP. I'm stucked because when I initiate the driver, by calling nrf_drv_twi_init, software craches jumping to function app_error_fault_handler.

My function to initialise TWI:

void twi_init (void)
{
ret_code_t err_code;

if (!nrf_drv_gpiote_is_init())
{
err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);
}
nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
err_code = nrf_drv_gpiote_out_init(PIG_READER_SCL_PIN, &out_config);
APP_ERROR_CHECK(err_code);
err_code = nrf_drv_gpiote_out_init(PIG_READER_SDA_PIN, &out_config);
APP_ERROR_CHECK(err_code);

const nrf_drv_twi_config_t twi_bq24155_config = {
.scl = PIG_READER_SCL_PIN,
.sda = PIG_READER_SDA_PIN,
.frequency = NRF_DRV_TWI_FREQ_100K,
.interrupt_priority = APP_IRQ_PRIORITY_HIGH,
.clear_bus_init = true
};

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

nrf_drv_twi_enable(&m_twi);
}

Code is running on PCA10040, nRF5_SDK_17.0.2_d674dde

What I'm doing wrong?

Related