cancel
Showing results for 
Search instead for 
Did you mean: 

I2C TXIS never set

joel23
Associate II
Posted on July 22, 2015 at 13:21

I am using the STM32F7 Discovery board (STM32F746NG) with an external I2C slave connected via the headers (I2C1 with PB8 and PB9). The I2C peripheral in the F7 is the same as the one in the F3, F0 and other STM32 devices (some people refer to it as I2Cv2).

I am trying to send a byte of data to the I2C slave (master transmitter mode). With my oscilloscope / logic analyer I can see that the correct address is being transmitted and that the slave returns an ACK. However, after the ACK nothing happens. This is due to the fact that my code keeps hanging in the loop that waits for the TXIS bit going high (which would indicate that I can now send data by writing to the TXDR register).

My (very well commented) code can be found in the attachments or here:  http://paste.ugfx.org/show/b0d08c2bd1

The i2cSendByte() function never returns. It keeps waiting in the while loop on line 78. I added the extra check inside the loop which would return in case of a NACK is received, but that is not the case either.

Any ideas? Did I configure the I2C wrong? Did I miss a bit somewhere?

I have also tried setting the NBYTES to two instead of one in case of the address is already counted as a byte. This did not change the result at all.

#stm32f7 #i2c
1 REPLY 1
joel23
Associate II
Posted on July 23, 2015 at 00:57

Issue fixed. Turns out that the CR2 register needs to be written to atomically. Working sources can be found here: 

http://seriouslyembedded.com/stm32f7-i2c-hal/