2024-10-27 11:36 AM
Hi, I'm giving the example of the two stm32 boards at this link
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
2024-10-27 07:37 PM
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
2024-10-30 08:35 AM - last edited on 2024-10-30 10:41 AM by Andrew Neil
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
2024-10-30 08:46 AM - edited 2024-10-30 08:47 AM
Hello @SDall
Please refer to the I2C examples Projects/STM32F401-Discovery/Examples/I2C available on STM32F4Cube firmware.
2024-10-30 08:51 AM - edited 2024-10-30 08:53 AM
There seems no reason to assume that this is the same issue as in that old thread:
@SDall wrote:using i2c protocol between 2 f401re, One master and another slave
That's a completely different situation!
Have you separately tested that
Without having first done those basic steps, you have no idea whether the problem(s) is/are in your Slave implementation or your Master implementation - or both!
See:
https://community.st.com/t5/stm32-mcus-boards-and-hardware/i2c/m-p/668411/highlight/true#M18743
@SDall wrote:the slave not riconozied address from master
Are you sure that the Master is actually sending the correct address?
Is your Slave responding with an ACK?
Have you used an oscilloscope to check what's happening on the wires?
@SDall wrote:i have horror on the slave, horror handle
What do you mean by "horror" here?
@SDall wrote:i ceked connection,
Show what connection you have.
Pullups?
2024-10-30 10:00 AM
yes already done and tried again about ten times, always the same error
2024-10-30 10:40 AM
So you're going to have to do some debugging to find out what, exactly, is going wrong.
Start by using an oscilloscope to check what's happening on the wires ...
2024-10-30 02:00 PM
Show your initialization code for the slave. How are you receiving data? Interrupt or polling?
Show your Master code and how you're transmitting..
Show your connection diagram between the two boards.
2024-10-30 02:48 PM
https://controllerstech.com/stm32-as-i2c-slave-part-1/
My code Is equal of this tutorial,master f 401,slave 401
The same configuration,exacrly connection inclusive gnd gnd,
No error in interrupt,the slave board Is in crash in debugging...
2024-10-30 02:58 PM
@SDall wrote:the slave board Is in crash in debugging...
What, exactly, do you mean by "crash" ?
Use the debugger to find how it gets into this "crashed" condition.
Again, use an oscilloscope to check what's happening on the wires
@SDall wrote:https://controllerstech.com/stm32-as-i2c-slave-part-1/
My code Is equal of this tutorial, master f401, slave 401
Well, that code is for F103 - not F401.
So why not, as @Saket_Om suggested, just use the example that is specifically for the F4 ?
Also, that Controllerstech code is not checking return values from the HAL functions.