cancel
Showing results for 
Search instead for 
Did you mean: 

Master board i2c don t comm with slave board, between 2 stm board

SDall
Associate II

Hi, I'm giving the example of the two stm32 boards at this link

https://github.com/sogongbang/STM32CubeF4/tree/master/Projects/STM32F4-Discovery/Examples/I2C/I2C_TwoBoards_ComPolling

I made and copied the connection and the code then I checked several times, everything matches, the problem is that when I execute the hall master i2c trasmitt function, it gives me an error, the master does not connect with the slave:

while(HAL_I2C_Master_Transmit(&I2cHandle, (uint16_t)I2C_ADDRESS, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 10000)!= HAL_OK)
{
/* Error_Handler() function is called when Timeout error occurs.
When Acknowledge failure occurs (Slave don't acknowledge it's address)
Master restarts communication */
if (HAL_I2C_GetError(&I2cHandle) != HAL_I2C_ERROR_AF)
{
Error_Handler();
}
}

The code stop in function Error_Handler()

Tanks

14 REPLIES 14

It doesn't mean your code is equivalent. You could have missed something from that tutorial. So post your code that you are working with. Attach your IOC file too.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
SDall
Associate II

I m Sorry but i m using two f 401 re ,connection Is ok, ,firmawer Is last ,but the slave don t receive,don t aknoweledge tò master.....

 

So, again, have you used an oscilloscope to see what's actually happening on the wires?

Have you separately debugged your master code, and your slave code?

 

Shirley.Ye
ST Employee

please check your code for i2c initialization. what is the i2c address? and how about the IO configuration? (make sure to configure the pin as the AF open Drain mode)

Hi,

The example given on github doesn't include pullups. If it has been copied verbatim, that'll be the problem...

I hope this helps.

Kind regards
Pedro

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.