AnsweredAssumed Answered

STM32F407 I2C

Question asked by Parmin Nayani on Jan 31, 2017
Latest reply on Feb 18, 2017 by Parmin Nayani

Hi All,

I m trying to use I2C on STM32F104. Here is my init code. I am not able to read an EEPROM. To test I sent data (I2C_SendData(I2C2, (uint8_t) 0x100);) in a loop (with a small delay), and monitored SCL and SDA pins on scope. There are absolutely no pulses on the pins. What could be wrong with the code? I await your help. Thanks.
void Config_I2C2 (void)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    I2C_InitTypeDef I2C_InitStructure;

 

    GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
    GPIO_Init(GPIOB, &GPIO_InitStructure);

 

    GPIO_PinAFConfig(GPIOB, GPIO_PinSource10, GPIO_AF_I2C2);
    GPIO_PinAFConfig(GPIOB, GPIO_PinSource11, GPIO_AF_I2C2);

 

    I2C_InitStructure.I2C_ClockSpeed = 10000;
    I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
    I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
    I2C_InitStructure.I2C_OwnAddress1 = 0xF0;
    I2C_InitStructure.I2C_Ack = I2C_Ack_Disable;
    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;

 

    I2C_Init(I2C2, &I2C_InitStructure);
    
    I2C_Cmd(I2C2, ENABLE);
}

Param

Outcomes