For some reason it seems that the TWI master does not generate a NACK. As a consequence, the TWI slave keeps sending data. I have managed to create a very simple function that should generate a NACK:
// ----------------------------------------------------------------------------------------------------
// I2C Read
// ----------------------------------------------------------------------------------------------------
uint8_t i2c_read (uint8_t ack)
{
// ------------------------------------------------------------------------------------------------
// Auxiliary variables
// ------------------------------------------------------------------------------------------------
uint8_t data;
// ------------------------------------------------------------------------------------------------
// Wait for data
// ------------------------------------------------------------------------------------------------
while (NRF_TWI1->EVENTS_RXDREADY == 0) { }
// ------------------------------------------------------------------------------------------------
// In case of the last byte, generate a stop condition before reading the byte
// ------------------------------------------------------------------------------------------------
if (ack == 0) {
NRF_TWI1->TASKS_STOP;
}
// ------------------------------------------------------------------------------------------------
// Read the byte
// ------------------------------------------------------------------------------------------------
data = NRF_TWI1->RXD;
// ------------------------------------------------------------------------------------------------
// Return data
// ------------------------------------------------------------------------------------------------
return data;
}
The function should generate a NACK is the parameter of the function is zero. Then the function creates a STOP task before it reads the data. According to the product specification, the implementation should be right.
I am using nRF52-DK + nRF5 (16.0.0) + SES.