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

SoftDevice safe TWI implementation not returning false on NACK

I’m running into a problem with the SoftDevice safe twi that’s been posted in the forums a few times. I got the file here:

devzone.nordicsemi.com/.../

One of my peripherals is the 24LC128 (linked to datasheet). To optimize bus throughput for writes, the 24LC128 uses acknowledgement polling. The quick description of this is that it takes a while to process a write command, so if you want to do multiple writes in a row, you repeatedly send the command byte to the 24LC128 until it acknowledges and then complete the write operation. It seems that for some reason the SD safe TWI implementation does not return false when it receives a NACK for a write, it only times out. I think the difference is in the twi_master_write(uint8_t * data, uint8_t data_length, bool issue_stop_condition) method. In the normal hw_twi file it checks NRF_TWI1->EVENTS_ERROR and returns false if this is not zero. I think this is where a false is returned if the peripheral does not ACK. This is missing from the SoftDevice safe code.

I don’t want to mess around in the sd_twi_hw_master.c file because I’m not familiar with the intricacies of the SoftDevice and how it plays with PPI and TWI, but it seems like it might be as simple as adding in the check from the normal twi file into the SoftDevice safe version. Can someone advise me on how to proceed here? I’ve attached the sd_twi_hd_master.c file that I am currently using for reference.

sd_twi_hw_master.c

Thanks! Seth

Related