Skip to main content
SDall
Associate III
October 27, 2024
Question

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

  • October 27, 2024
  • 4 replies
  • 2971 views

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

4 replies

jiangfan
ST Employee
October 28, 2024

Please be sure to use same Hardware configuration as mentioned with 2 STM32F4-Discovery boards:

Hardware and Software environment
- STM32F4-Discovery RevB & RevC Set-up
- Connect Master board PB6 to Slave Board PB6
- Connect Master board PB9 to Slave Board PB9
- Connect Master board GND to Slave Board GND

 

SDall
SDallAuthor
Associate III
October 30, 2024

Originally a reply in this old thread from 2017: https://community.st.com/t5/stm32-mcus-products/i2c-always-falls-into-hal-i2c-error-af/td-p/399752/page/2

 

Hi Tiago i m using i2c protocol between 2 f 401 re,One master and another slave ,i have the same problem the slave not riconozied address from master ,i have horror on the slave ,horror handle ,i ceked connection,shift register, all,Always same error

Technical Moderator
October 30, 2024

Hello @SDall 

Please refer to the I2C examples Projects/STM32F401-Discovery/Examples/I2C available on STM32F4Cube firmware.

 

 

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question.Saket_Om"
SDall
SDallAuthor
Associate III
October 30, 2024

yes already done and tried again about ten times, always the same error

SDall
SDallAuthor
Associate III
November 4, 2024

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.....

 

Andrew Neil
Super User
November 4, 2024

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?

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Shirley.Ye
ST Employee
November 6, 2024

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)

PGump.1
Senior II
November 6, 2024

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.