cancel
Showing results for 
Search instead for 
Did you mean: 

How to reduce the I2C speed ?

I am working on a STM32F746G-DISCO with I2C got on Arduino style board.

I would like to reduce the I2C speed because sometime this lock my app with some external DAC chip.

At this time I am using:

CAMERA_IO_Init();
 
BSP_TS_Init(480, 272);
 
 
and these function to read and write the reg on external DAC chip 
 
CAMERA_IO_Write(0x90, 8, 0b10011001); 
 
reg11 = CAMERA_IO_Read(0x90, 11);

4 REPLIES 4
TDK
Guru

The clock speed is set within the I2C initialization function. The relevant register is I2C->TIMINGR.

If you feel a post has answered your question, please click "Accept as Solution".

Probably I have found the point where to set it

Could you confirm this ?

static void I2Cx_Init(I2C_HandleTypeDef *i2c_handler)
{
  if(HAL_I2C_GetState(i2c_handler) == HAL_I2C_STATE_RESET)
  {
    if (i2c_handler == (I2C_HandleTypeDef*)(&hI2cAudioHandler))
    {
      /* Audio and LCD I2C configuration */
      i2c_handler->Instance = DISCOVERY_AUDIO_I2Cx;
      //i2c_handler->Instance = DISCOVERY_EXT_I2Cx;
    }
    else
    {
      /* External, camera and Arduino connector  I2C configuration */
      i2c_handler->Instance = DISCOVERY_EXT_I2Cx;
    }
 
#define DISCOVERY_I2Cx_TIMING_ORIG                      ((uint32_t)0x40912732)
#define DISCOVERY_I2Cx_TIMING_NEW                      ((uint32_t)0x10911823)
#define DISCOVERY_I2Cx_TIMING_NEW1                      ((uint32_t)0x00611116)
 
    i2c_handler->Init.Timing           = DISCOVERY_I2Cx_TIMING_NEW1;
    i2c_handler->Init.OwnAddress1      = 0;
    i2c_handler->Init.AddressingMode   = I2C_ADDRESSINGMODE_7BIT;
    i2c_handler->Init.DualAddressMode  = I2C_DUALADDRESS_DISABLE;
    i2c_handler->Init.OwnAddress2      = 0;
    i2c_handler->Init.GeneralCallMode  = I2C_GENERALCALL_DISABLE;
    i2c_handler->Init.NoStretchMode    = I2C_NOSTRETCH_DISABLE;
 
    /* Init the I2C */
    I2Cx_MspInit(i2c_handler);
    HAL_I2C_Init(i2c_handler);
  }
}

Why I have no I2C bus problems using the EXT/RF E2P connector (pin EXT_SDA/EXT_SCL) instead of CN7 connector (pin SDA/SCL) ?

Is this the point to modify the freq ?

 
 
//#define DISCOVERY_I2Cx_TIMING_ORIG                     ((uint32_t)0x40912732)
//#define DISCOVERY_I2Cx_TIMING_NEW                     ((uint32_t)0x10911823)
//#define DISCOVERY_I2Cx_TIMING_NEW1                     ((uint32_t)0x00611116)
 
 
   i2c_handler->Init.Timing          = DISCOVERY_I2Cx_TIMING;

TDK
Guru

Here's what the code says about that parameter:

  uint32_t Timing;              /*!< Specifies the I2C_TIMINGR_register value.
                                  This parameter calculated by referring to I2C initialization
                                         section in Reference manual */

If you feel a post has answered your question, please click "Accept as Solution".