2020-11-04 10:34 AM
I am simply trying to read a few bytes from an I2C memory device using the following code:
uint8_t buff[ 4 ];
HAL_I2C_Mem_Read( &hi2c1, ( uint16_t )( 80 << 1 ), 0, I2C_MEMADD_SIZE_16BIT, buff, 4, 10 );
However, when I look at the output on the logic analyser, 1)The slave address does not appear on the bus and 2)I get continuous clocks that never stop).
Can anyone help ?
Andy
2020-11-04 12:41 PM
Ensure pins are correctly initialized. Probably want a bigger timeout than 10ms.
2020-11-04 02:45 PM
Thanks for your comments however, the pins are initialised using STM32CubeMX generated code:
/**I2C1 GPIO Configuration
PB8 ------> I2C1_SCL
PB9 ------> I2C1_SDA
*/
GPIO_InitStruct.Pin = EEPROM_SCL_Pin|EEPROM_SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
__HAL_AFIO_REMAP_I2C1_ENABLE();
/* I2C1 clock enable */
__HAL_RCC_I2C1_CLK_ENABLE();
Also, increasing the timeout makes no difference.
Andy