Platform: Keil, SDK13.1, nRF52832
I'm investigating series of seemingly random hangs when app_twi gets permanently stuck in app_twi.c
following code snippet:
When this happens SCL line is permanently pulled low. I thought that it may be due to clock stretching and checked if one of slave devices is misbehaving. I wasn't able to to find anything on slave side.
One of my slave devices (Atmel Tiny MCU) has a way to tell if it's holding SCL line. While similar lock happened I was able to check that SCL was held by master (as far as you can trust ATTiny register values). I was also able to reset the slave and this haven't released SCL. However resetting nRF52 (master) caused SCL release.
So I think that's something wrong with app_twi master implemetation.
This code snippet can reliably cause symptoms I've described above:
test_case(1)
works as expected while test_case(0)
reliably causes app_twi
to get stuck as on attached Saleae trace /cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-010a9164018145d884c8f96862005e33/twi_5F00_hang.logicdata and register view screenshot
While this happens SCL is permanently pulled low. Resetting nRF52 gets communication working again.
This is just an example. Hangs I'm experiencing happen in various configurations of TWI read/write operations.
Am I doing something wrong?
What can be done to debug this?
I'm observing similar problems in devices already deployed in the field and I'd appreciate pointer towards solving this.