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

TWIM XFER Hangs Unless NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER used as a flag

Hello! 

I have this interesting bug with the twim driver.

It works perfectly with the NRFX_TWIM_XFER_TXRX transfer type: I see the transaction go out on the bus lines and the interrupt calls my handler when the transfer is complete. 

When I switch the xfer type to NRFX_TWIM_XFER_TX, however, I get the following: 

1) The transaction occurs successfully: I see the start and stop bits and all the bits in between are as expected. 

2) My handler is never called. 

3) If I poll wait using 'nrfx_twim_is_busy', it never leaves the while loop. 

4) If I use the NRFX_TWIM_FLAG_NO_XFER_EVT_HANDLER flag, the data goes out on the pins, the handler is never called (as expected) BUT 'nrfx_twim_is_busy' eventually 

    returns 'false'. 

What am I missing? I see that I have to enable EasyDMA on the active Twim instance for the project to compile but I don't have any easy DMA code setup. 

  • 1) Noted: I will use the APP_ERROR_CHECK (or other suitable logging method) moving forward. Thank you for pointing me to the logger page. I am currently using the RTT debug option through my J-Link but I would definitely like to store debug messages in flash and retrieve them later after running for a long time. 

    2) We went on a side mission haha but I'm still having trouble with the original ticket. The interrupt after calling nrfx_twim_xfer with the NRFX_TWIM_XFER_TX type works but never calls the handler when the transfer 

    is complete. Are you able to duplicate this with the SDK 16? 

  • Thank you for your patience.

    Julio said:
    Noted: I will use the APP_ERROR_CHECK (or other suitable logging method) moving forward.

    Great, I am glad to hear that!

    Julio said:
    Thank you for pointing me to the logger page.

    No problem at all, I am happy to help. 

    Julio said:
    We went on a side mission haha but I'm still having trouble with the original ticket. The interrupt after calling nrfx_twim_xfer with the NRFX_TWIM_XFER_TX type works but never calls the handler when the transfer 

    Hehe yes, suddenly we had diverged from the original issue.
    So, back to the initial issue: would it be possible for you to share the entire main.c file with me? It would be a lot easier to look through the initialization when I also could see what the different parameters used actually point to. Especially so if you have already made changes to the code since you shared it last.

    If there is an issue of sharing the code publicly here please let me know so I can make the ticket private - only viewable by yourself and the support staff here at Nordic.
    Please let me know if you would like me to do so before you share the code.

    Looking forward to resolving this issue together,

    Best regards,
    Karl

  • Hi Karl, 

    I cannot share that code publicly. I made sure to scrub the code I did share to remove sensitive information. Such a task would be too much for the entire main.c (and additional source code). 

    Are you unable to duplicate this? It's a pretty straightforward phenomenon. If you have good, known working code that does what I am attempting to do, please post it.  This is a minor problem thats been more my curiosity than a real problem. 

  • Hello Julio,

    Julio said:
    I cannot share that code publicly. I made sure to scrub the code I did share to remove sensitive information. Such a task would be too much for the entire main.c (and additional source code).

    As I said, I can make the ticket here private - so that it is only viewable for you yourself, and the support staff here at Nordic.
    Would this allow you to share the code?

    Julio said:
    If you have good, known working code that does what I am attempting to do, please post it.  This is a minor problem thats been more my curiosity than a real problem. 

    I have never heard about this specific issue before - so I have not created an example for this - but the twi_sensor example is a minimal implementation that does this with an _RX transaction without problem. If you have defined and set NRF_DRV_TWI_USE_TWIM in your sdk_config, the example will use the TWIM driver.
    Could you run this example - replacing the default pins and addresses in the example with those relevant for your device - and see if you are seeing the same behavior?

    Seeing the code would undoubtedly be helpful in order to efficiently debug this - but if this is not possible I'm sure we will be able to make due.

    Best regards,
    Karl

Related