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

How to reset TWI during async operation

Hi,

I have setup TWI peripheral for async transfers via IRQ and callback. After firing the transfer operation, I feel uneasy about having no control until the interrupt happens. Sometimes while playing with TWI wires I've been able to lock the bus, i.e. a TWI operation is initiated but the IRQ handler is never called anymore, also blocking further operations. Due to the async nature, my idea is to start/stop an app timer (single mode, 200ms) on every I2C operation. I'm not sure is the best solution, since I continuously start/stop the timer on each TWI operation and I fear this can interfere with SoftDevice.

  • If the operation completes, I stop the timer from the TWI handler.
  • If the timer handler is called instead, it means I have a pending operation on the TWI driver. I need to gracefully cleanup the TWI hw/sw related stuff and pass an error to the application layer. What's the suggested way of doing this?

I am using SDK 14.2, SoftDevice and app timers with the scheduler (not sure this may be important).

Thanks!

Parents
  • Hi,

    What you describe is something that happens during prototype development, while doing various debugging etc. However once mounted on the same PCB and the firmware is tested, I am not aware of anyone actually taking any specific precautions for twi transfers. What you describe I would say is more common for UART transfers, however feel free to add safety mechanisms as you like.

    Best regards,
    Kenneth

Reply
  • Hi,

    What you describe is something that happens during prototype development, while doing various debugging etc. However once mounted on the same PCB and the firmware is tested, I am not aware of anyone actually taking any specific precautions for twi transfers. What you describe I would say is more common for UART transfers, however feel free to add safety mechanisms as you like.

    Best regards,
    Kenneth

Children
No Data
Related