Skip to main content
Visitor II
October 27, 2024
Question

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

  • October 27, 2024
  • 4 replies
  • 2970 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

    This topic has been closed for replies.

    4 replies

    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

     

    SDallAuthor
    Visitor II
    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.

     

     

    SDallAuthor
    Visitor II
    October 30, 2024

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

    SDallAuthor
    Visitor II
    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.....

     

    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?

     

    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)

    Graduate 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