cancel
Showing results for 
Search instead for 
Did you mean: 

Impact of Clock Stretching and Applicability of Slave Features in STM32CubeIDE

AA.27
Associate II

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:

  1. If I enable or disable Clock Stretching (listed under Slave Features), will it cause issues or improve my master communication?
  2. In STM32CubeIDE, are the Slave Features settings only applicable when STM32 is configured as a slave? Or can I still modify them when STM32 is in master mode, and will they have any effect?

I would appreciate any clarification on these points

1 REPLY 1
padawan
Senior
/* 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