2022-02-17 06:15 AM
I am using a stm32g071 as an I2C slave.
Problem is, that I2C_SlaveTxCpltCallback() callback is called even when the master read one byte less than previously configured.
I.e. With RXSIZE = 4 (as in code below),
I tested other numbers, and generally the DMA sets the TC flag if N-1 bytes were transferred and the master sends a stop condition (or NACK).
Code excerpt is below. Unfortunately you will need a second device to reproduce this. Could this be a hardware issue?
void I2C_AddrCallback(uint8_t TransferDirection, uint16_t AddrMatchCode)
{
(void) AddrMatchCode;
if (TransferDirection == I2C_DIRECTION_RECEIVE) {
HAL_I2C_Slave_Seq_Transmit_DMA(&m_i2c, data, 4, I2C_NEXT_FRAME);
} else { // I2C_DIRECTION_TRANSMIT (from master perspective)
...
}
}