We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi
Just to inform people that in some cases and with certain devices the function I2C_Send7bitAddress in STM32 FwLib is not working correctly and does not trigger the event I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED so the run of the program gets stuck into an infinite while loop.
I would recommend to use the code below to replace the I2C_Send7bitAddress if you encounter issues with I2C on STM32 :
// send address //I2C_Send7bitAddress(I2Cx, address, direction); // not working if(direction == I2C_Direction_Transmitter) I2C_SendData(I2Cx, (address << 1) | 0); else if(direction == I2C_Direction_Receiver) I2C_SendData(I2Cx, (address << 1) | 1); // check if slave acknowledged his address within timeout if(direction == I2C_Direction_Transmitter) while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); else if(direction == I2C_Direction_Receiver) while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));
Here is a related thread talking about this issue: http://www.keil.com/forum/18440/
Romain