Dear DevZone Team
To detect possible TWI slave devices connected on a TWI bus, we want to scan for device addresses and check if they are being acknowledged.
In the twi_scanner example found within the nRF5 SDK, the scanning is solved by reading one byte from the desired address if it is ACK'ed.
Yet, we want to prevent reading or writing any additional data after checking the ACK of the address byte.
Against the product specification, we set the TWIM TXD.MAXCNT = 0 and then start the transmission with TASKS_STARTTX = 1.
- If the address is NACK'ed, EVENTS_ERROR is set and the transmission can be stopped. -> No slave device is available on this address.
- If the address is ACK'ed, no further data is sent but also no STOPPED or LASTTX event is generated. Nonetheless, a short timeout can be awaited before the transmission can be stopped. Since the EVENTS_ERROR is not set, one can assume that an ACK has been received. -> Slave device is available on this address.
Is this a viable approach to implement TWI bus scanning or do you advise against this solution? If there is a solution adhering to the specification please let me know as well.
Thank you in advance!
Best regards,
Pascal