cancel
Showing results for 
Search instead for 
Did you mean: 

how to send data from salve to master in i2c?

adam.wu
Associate II

I have two i2cs, i2c1 and i2c2, I set i2c1 as master and send data request (a "0" char) to i2c2, which is set as slave. now I have enabled event interrupt in i2c2, and when i2c1 sends command, I could find the default MX generated interrupt function in i2c2 is used, so interrupt function works.

Now how to let the slave response via interrupt function?

I tried to use HAL_I2C_Slave_Receive() + HAL_I2C_Slave_transmit(), i.e, i2c1-->(send "0" command)-->i2c2, i2c2 receives the command and check whether it is "0", then i2c2->(send data back)--->i2c1. but HAL_I2C_Slave_Receive() (activated by flag in interrupt function) just hang up and could not get value, clock is always low

It sounds very normal and appreciated if you know how to use HAL functions)

1 REPLY 1
KnarfB
Principal III

There was a related post recently, search for "STM32F072 I2C slave Receive callback"