2015-08-17 10:18 PM
I have been trying to use the latest HAL drivers, make thing easier once you understand their complexity. I am up to trying to get the I2C port working. i have no activity on the I2C bus at all the pins remain high all the time. If I bit bang I can get a respoonse from the slave. So the hardware is ok. i am using I2C2 on the F407VG processor
The init code is GPIO_InitTypeDef I2C2_init; I2C2_init.Pin=GPIO_PIN_10 | GPIO_PIN_11; I2C2_init.Mode=GPIO_MODE_AF_OD; I2C2_init.Pull=GPIO_PULLUP; I2C2_init.Speed=GPIO_SPEED_LOW; I2C2_init.Alternate=GPIO_AF4_I2C2; HAL_GPIO_Init(GPIOB,&I2C2_init); then __HAL_RCC_I2C2_CLK_ENABLE(); then the I2C setup I2C_HandleTypeDef hi2c2; hi2c2.Instance = I2C2; hi2c2.Init.AddressingMode =I2C_ADDRESSINGMODE_7BIT; hi2c2.Init.ClockSpeed=10000; hi2c2.Init.DualAddressMode=I2C_DUALADDRESS_DISABLE; hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_16_9; hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE; hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; hi2c2.Init.OwnAddress1=0; hi2c2.Init.OwnAddress2=0; HAL_I2C_Init(&hi2c2); then using the following i2c_status=HAL_I2C_Master_Transmit(&hi2c2,208,rtcBuff,7,200); slave address is 208 from rtcBuff 7 bytes time out 200 i get i2c_status as always being HAL_BUSY but no bus activity. Clearly I have missed something. Any suggestions? #i2c #stm32f4072015-08-19 04:15 AM
Hi,
1. The I2C flag is busy? 2. GPIO Clocks are enabled? You can try to:1. change the IOs speed, 2. If not search other SDA/SCL Pins, 3. You can take a look to one I2C examples under STM32Cube_FW_F4 package, it can be very helpful.-Syrine-2015-08-30 06:24 PM
Hi Thanks for the comment. I reduced the speed and the slave now responds ok.
regrads and thanks Mark