AnsweredAssumed Answered

i2c Hard Reset Issue

Question asked by Pachchigar.Pinkesh on Apr 20, 2016
Latest reply on Apr 22, 2016 by FTITI.Walid
Hi,
In our environment , we have interfaced codec IC with I2C peripheral .
Once codec IC has been configured , both SDA and SCL @ High logic level .
Now if controller reset happened , SDA line remains low and inhibits the STM32 start condition .

To resolve this, I have written following code .
Now if I go for configuring I2C peripheral ,busy flag has been set just after RCC_APB1PeriphClockCmd() API .

Any reason behind this ?

void ResetI2cLines()
{
    uint8_t i;
    GPIO_InitTypeDef gpio;

    // Provid delay before I2c Reset line
    DelayMS(1);

    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);

    // Config SDA and SCL Pin
    bzero(&gpio, sizeof(gpio));
    gpio.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
    gpio.GPIO_Mode = GPIO_Mode_OUT;
    gpio.GPIO_OType = GPIO_OType_PP;
    gpio.GPIO_PuPd = GPIO_PuPd_UP;
    gpio.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOB, &gpio);

    GPIO_SetBits(GPIOB, GPIO_Pin_7);

    // 9th Pulse NACK signal
    for(i=0; i<10; i++)
    {
        // SCL line Clocking
        GPIO_SetBits(GPIOB, GPIO_Pin_6);
        DelayUS(5);
        GPIO_ResetBits(GPIOB, GPIO_Pin_6);
        DelayUS(5);
    }

    //Stop Signal - SDA Low to High while SCL High
    GPIO_ResetBits(GPIOB, GPIO_Pin_7);
    DelayUS(5);
    GPIO_SetBits(GPIOB, GPIO_Pin_6);
    DelayUS(2);
    GPIO_SetBits(GPIOB, GPIO_Pin_7);
    DelayUS(2);
}

Outcomes