cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F427 HAL I2C Slave

Chr. Fahrni
Associate II
Posted on May 13, 2014 at 09:44

Hello

I work with STM32CubeMX with Keil and to realize a I2C Slave withe the STM32F427.

I have 2 questions:

  • STM32CubeMX: I2Cx Configuration: Primary slave address is a 7bit value --> 0..127

    In the file stm32fxx_hal_i2c.c the OAR1-Register will be initialized like:

    hi2c->Instance->OAR1 = (hi2c->Init.AddressingMode | hi2c->Init.OwnAddress1);

    In my opinion the OwnAddress1 needs to be shiftet left for 1 bit.
  • Doing a HAL_I2C_Slave_Receive_IT() the function

    HAL_CAN_IRQHandler() will be called in stm32f4xx_it.c. According the documentation there should be a callback to HAL_I2C_SlaveRxCpltCallback. In HAL_I2C_EV_IRQHandler I do not find any callback request...
Thanks a lot for reading and finding a solution.

 C Fahrni

#hal #stm32 #i2c #i2c #hal
2 REPLIES 2
Posted on June 23, 2014 at 12:02

Hello C Fahrni,

Could you please attach your project .ioc file, to have enough insight into what specifically you are doing.

What version of CubeMX are you using ?

With regard.

Posted on June 27, 2014 at 11:48

Hi C Fahrni,

Please find below the answers to your questions:

  • STM32CubeMX tool will be enhanced in order to shift left for 1 bit the OwnAddress1 to bypass this limitation when configuring I2C peripheral.
  • Within the slave receiver, the last event is the detection of stop flag, handled by I2C_Slave_STOPF() where the HAL_I2C_SlaveRxCpltCallback(hi2c) is called.
Hope this will help you.

With regards.