AnsweredAssumed Answered

HAL I2C problems

Question asked by barber.mark on Aug 18, 2015
Latest reply on Aug 31, 2015 by barber.mark
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?

Outcomes