Issue with NRF_TWIM_TASK_STOP and NRF_TWIM_EVENT_STOPPED on NRF52833 DK

Issue:

While trying to initialize and check the viability of an I2C interface using TWIM, my NRF_TWIM_TASK_STOP never triggers NRF_TWIM_EVENT_STOPPED.

Code:

nrf_twim_task_trigger(reg, NRF_TWIM_TASK_STOP);
while (nrf_twim_event_check(reg, NRF_TWIM_EVENT_STOPPED) == 0) {
    printf("IN WHILE WAITING FOR (NRF_TWIM_EVENT_STOPPED == 1)\n");
}

This causes the "IN WHILE" message to print indefinitely.

Wondering how I can verify that the trigger is being pushed to the correct address, and diagnose why the event is not getting fired.

Cheers!

Parents
  • Update:

    Having run some rather exhaustive tests, I have the following update

    1) Triggering the NRF_TWIM_TASK_STOP event using nrf_twim_task_trigger causes an NRFX_ERROR_INTERNAL error. I can get no further information.
    2) Calling nrfx_twi_bus_recover succeeds, and the bus is recovered.

    This allows my method to return a proper TWI interface using the discovered address.

    Questions:
    1) What kinds of issues would produce the aforementioned error code?
    2) Is there any way to get further/deeper information on the error?

    Best,


    S.

  • Hi,

    Where do you get the NRFX_ERROR_INTERNAL error from? As far as I can see, nrf_twim_task_trigger() should return void.

    Do you have one/some specific TWI slave devices connected to the bus? We added a fix to the nrfx_twim driver in nrfx v1.8.0, to resolve issues caused by TWI devices not behaving according to spec: https://github.com/NordicSemiconductor/nrfx/blob/master/CHANGELOG.md#fixed-7

    Best regards,
    Jørgen

  • The error is coming from debugging code I've added. e.g.

    if (nrf_twim_event_check(reg, NRF_TWIM_EVENT_ERROR)) {
        printf("nrf_twim_event_check(reg, NRF_TWIM_EVENT_ERROR) returned true\n");
    
        uint32_t err_src = nrf_twim_errorsrc_get_and_clear(reg);
        nrfx_err_t err_code = twi_process_error(err_src);
        printf("nrf_twim_errorsrc_get_and_clear(%d) returned %d \n", reg, err_code);
        nrf_twim_event_clear(reg, NRF_TWIM_EVENT_ERROR);
    }


    The number can then be checked against an nrfx_err_t to decode the error.

    I have two TWI slave devices, but only am only using one at a time.

    I'm currently using nrfx v2.0.

    Cheers,

    S.

Reply
  • The error is coming from debugging code I've added. e.g.

    if (nrf_twim_event_check(reg, NRF_TWIM_EVENT_ERROR)) {
        printf("nrf_twim_event_check(reg, NRF_TWIM_EVENT_ERROR) returned true\n");
    
        uint32_t err_src = nrf_twim_errorsrc_get_and_clear(reg);
        nrfx_err_t err_code = twi_process_error(err_src);
        printf("nrf_twim_errorsrc_get_and_clear(%d) returned %d \n", reg, err_code);
        nrf_twim_event_clear(reg, NRF_TWIM_EVENT_ERROR);
    }


    The number can then be checked against an nrfx_err_t to decode the error.

    I have two TWI slave devices, but only am only using one at a time.

    I'm currently using nrfx v2.0.

    Cheers,

    S.

Children
No Data
Related