cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F105 I2C1 problem

nps
Associate II
Posted on March 15, 2015 at 15:22

Hi guys,

Sorry to trouble you frequently. Can't help!! I have an STM32F105VC (100 pin device). Trying to use I2C bus on pins 95, 96. This is I2C1 (PB8, PB9) and requires remap (as per documentation). Did the following init. Not able to read or write. Here is the init code. Same code without remap but on I2C2 worked on a 64 pin device (STM32F103RC).

void I2C1_Configure (void)

{

    // First remap pins.

    GPIO_PinRemapConfig(GPIO_Remap_I2C1,ENABLE);

    GPIO_InitStructure.GPIO_Pin =  I2C_EE_SCL | I2C_EE_SDA;

//    GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_8 | GPIO_Pin_9;

    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;

    GPIO_Init(GPIOB, &GPIO_InitStructure);

    /* I2C configuration */

    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_Enable;

    I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;

    I2C_InitStructure.I2C_ClockSpeed = 80000;

    I2C_Init(I2C1, &I2C_InitStructure);

    /* I2C Peripheral Enable */

    I2C_Cmd(I2C1, ENABLE);

}

1 REPLY 1
nps
Associate II
Posted on March 17, 2015 at 02:26

Well after some searching I found that there is a bug in the device (105) itself. Any one facing similar problem, please go through errata of the particular device (or is it better/safer to go through the errata before choosing a device). I have implemented the workaround suggested in the errata and it started working but not without a problem. Thanks.