i2c
- April 22, 2024
- 4 replies
- 3510 views
Hi,
I now implementing i2c with 2 stm board.
The process is
1. Master transmit data
2. Slave receive and calculate some functions.
3. Slave transmit that changed data
4. Master receive it.
with HAL_I2C functions.
I measure the SDA line with logic analyzer, and the results are unexpected..
As you can see in the code, I transmitt 3.1416 to slave repeatedly.
and in the slave ProcessData function, TX_Buffer_1 updated 1 or 0.111 randomly . (random but the probability of 1 must be higher than 0.111)
As a result , the very first data transmit & receive & calculate & transmit well (left picture)
but after that, every data show 0.111 (right one)

I check RX_Buffer_1 in slave with PuTTY,
RX_Buffer _1 printed
3.1416
0
0
0
0
... which means except first data, slave receive 0 everytime...
but master still transmit 3.1416 (I checked it both logic analyzer and PuTTY)
Plz help :( idk what's the problem....
I attached master and slave main.c file. thank you
summary----------------------------------------------------------
1. master transmit 3.1416 reapetedly
2. slave receive 3.1416 at first, but after that, slave receive 0.
