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

Question about using the TWI

Hello, I am currently using the TWI in non-blocking mode, however I frequently run into the issue where the code gets stuck on nrf_drv_twi_tx. function at the return result statement. I can't step in or out of the code. I have also encountered this intermittently - It happens less when I step through the code, and happens immediately if I let the code run.

The circuit is guaranteed to work because it has been flashed with firmware and that can retrieve value from the sensor I'm using, so I'm sure there is something wrong with how I understand the twi code.

My question is why my code works when I step through it, but fails when I let it run?

Parents
  • Hi,

    I frequently run into the issue where the code gets stuck on nrf_drv_twi_tx. function at the return result statement.

    What do you mean by stuck? Do the function return a non-zero error code that puts the chip into the error handler?

    Can you post the code you used for initializing TWI and how you start and finish transfers?

    How do you ensure that the transfer is completed before starting a new transfer? In non-blocking mode, you need some synch method to make sure that no transfers are ongoing before starting a new transfer. If the application works as expected when stepping, this could indicate that the this allows enough time for the previous transfer to complete before a new transfer is stared.

    Best regards,
    Jørgen

Reply
  • Hi,

    I frequently run into the issue where the code gets stuck on nrf_drv_twi_tx. function at the return result statement.

    What do you mean by stuck? Do the function return a non-zero error code that puts the chip into the error handler?

    Can you post the code you used for initializing TWI and how you start and finish transfers?

    How do you ensure that the transfer is completed before starting a new transfer? In non-blocking mode, you need some synch method to make sure that no transfers are ongoing before starting a new transfer. If the application works as expected when stepping, this could indicate that the this allows enough time for the previous transfer to complete before a new transfer is stared.

    Best regards,
    Jørgen

Children
No Data
Related