2025-02-17 09:58 PM
I am using the STM32F413VHT6 board and configuring I2C in STM32CubeIDE with STM32 as a master. I have the following questions regarding the Clock Stretching feature and Slave Features settings in the IDE:
I would appreciate any clarification on these points
2025-02-18 04:12 AM
/* I2C1 init function */
void MX_I2C1_Init(void)
{
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = 0x00702991; // 400 Khz
// hi2c1.Init.Timing = 0x10909CEC;// 100Khz
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; // <------- Stretch enable
if (HAL_I2C_Init(&hi2c1) != HAL_OK)
Here it is. The effect is that a slave can keep the SCL line low. This tells the master that it is not yet finished with the internal calculations and does not want to send any data.
hth
padawan