cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F302: I2C slave transmitter nacking when no data is to be sent

prsteve521
Associate

Hello,

I'd like to have this feature implemented: if no data is to be sent, the I2C peripheral (in the slave mode) should not perform an ACK in case of an address match.

Of course, this wouldn't have to be an issue, if, for example, no data is ready, the interrupt routine would respond with a "no data" answer, for example sending 0xFF. However, I'm working with a codebase, where this behavior is not desired.

I was thinking about configuring the I2C peripheral in this way:
setting the SBC bit to 1 - if NBYTES=0 and the slave is addressed to send data to the master, what happens in this case?

Thank you in advance.

3 REPLIES 3
Pavel A.
Evangelist III

Maybe, disable the I2C while no data is ready? This is behavior of some I2C devices that do not stretch the clock: while busy they do not respond to addressing thus "replying NACK".

Unfortunately, this is not a solution. I need to be able to receive data too. My initial idea was that the peripheral would not respond if requested to send data while SBC=1 and NBYTES=0. If requested to receive data while SBC=1, the NBYTES could be reloaded to 0x01 (as 28.4.8 Slave byte control mode, RM0365 suggests).

I know this is an older thread and probably has been solved in some other, very likely better way.

The I2Cv2 hardware apparently does not support such behaviour. However, it just occured to me, that one way to issue a NAK upon detecting the "unwanted" read could be through disconnecting SDA at the GPIO level before the master clocks it in. This of course is untested, may result in some "funny" behaviour of the I2C peripheral, and I don't recommend it; just that it could be quite an interesting exercise to try it... would one have enough time for such experiments.

JW