Is there a way to send a NACK on I2C on STM32F407? There is no way to do that using the HAL, and the datasheet says nothing about it.
I think the following section explains how to generate the NACK. In order to send the NACK signal, the software must clear the ACK bit after reading second last byte. Hope this will help.
It is described in the Reference Manual, not in the datasheet. A
NACK is sent when the
I2C_CR1_ACK bit in
I2C->CR1 is set to
0 before receiving the last byte.
HAL should manage this bit automatically according to the transfer size in the
Sending a NAK by itself is pointless. The whole purpose of HAL is to handle the protocol for you, will generate a NAK or ACK bit when necessary. And surely the reference manual gives details how to make the I2C peripheral to transmit ACK or NAK after a byte transfer.