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?

Parents
  • Thank you Karl,

    Since I'm working with NUS need to compile and replicate the problem with another case, CTS.

    I'm also working with Eclipse, a bit different but could get following log:

    <info> app_timer: RTC: initialized.

    <info> app: Current Time service client started.

    <info> TWIM: Function: nrfx_twim_init, error code: NRF_SUCCESS.

    <info> TWIM: Instance enabled: 0.

    <info> TWIM: Transfer type: XFER_TX.

    <info> TWIM: Transfer buffers length: primary: 1, secondary: 0.

    <warning> TWIM: Function: nrfx_twim_xfer, error code: NRF_SUCCESS.

    <error> app: Fatal error

    The problem is not with nrf_drv_twi_init function but when initialize a transfer, in function nrfx_twim_xfer.

    Put log level to debug but result is the same.

    BR

    Paulo

  • Hello,

    Paulo Arede said:
    Thank you Karl,

    No problem Paulo, I am happy to help!

    Paulo Arede said:

    Since I'm working with NUS need to compile and replicate the problem with another case, CTS.

    I'm also working with Eclipse, a bit different but could get following log:

    What modifications have you made to the CTS example, before you began encountering this error?

    Paulo Arede said:

    The problem is not with nrf_drv_twi_init function but when initialize a transfer, in function nrfx_twim_xfer.

    Put log level to debug but result is the same.

    Could you show code for the section in which it encounters the error?
    It would be helpful to see what is happening. Have you used breakpoints to figure out of the code crashes at the same time, or after a certain function call? I find it strange that you receive a warning printout for the NRF_SUCCESS error code after the _xfer call returns. Have you made any changes to the logging here, other than changing the log level to debug? 
    The more specific information you can give, the faster we will identify and resolve your issue.

    Looking forward to resolving this issue together!

    Best regards,
    Karl

Reply
  • Hello,

    Paulo Arede said:
    Thank you Karl,

    No problem Paulo, I am happy to help!

    Paulo Arede said:

    Since I'm working with NUS need to compile and replicate the problem with another case, CTS.

    I'm also working with Eclipse, a bit different but could get following log:

    What modifications have you made to the CTS example, before you began encountering this error?

    Paulo Arede said:

    The problem is not with nrf_drv_twi_init function but when initialize a transfer, in function nrfx_twim_xfer.

    Put log level to debug but result is the same.

    Could you show code for the section in which it encounters the error?
    It would be helpful to see what is happening. Have you used breakpoints to figure out of the code crashes at the same time, or after a certain function call? I find it strange that you receive a warning printout for the NRF_SUCCESS error code after the _xfer call returns. Have you made any changes to the logging here, other than changing the log level to debug? 
    The more specific information you can give, the faster we will identify and resolve your issue.

    Looking forward to resolving this issue together!

    Best regards,
    Karl

Children
No Data
Related