AnsweredAssumed Answered

I2C pin config

Question asked by francescato.diego on May 18, 2015
Latest reply on May 19, 2015 by francescato.diego
My application use an I2C1-> 1wire network converter on STM32F407 device
At reset, after the I2C1 peripheral init, the application enumerate 1wire network and discover all connected devices.
But the user can also connect a new 1wire device and restart the enumeration process while application running
(Ok normally must shutdown the device before do it, but I know my customers...)
When new enumeration request start, my code
Disable i2c port
Deinit the port
and after short delay restart the I2C perhiperal with same config procedure called at reset
With  I2c peripheral disabled (all I2C1 regs are set to zero checked with emulator)
I call the GPIO pin config:

static void uB_I2C_GPIO_config (eI2CID id, I2C_INIT_T* i2c)
  GPIO_InitTypeDef  GPIO_InitStructure;
  GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;
  GPIO_InitStructure.GPIO_Pin   = i2c-> ; GPIO_Init(i2c->pin_scl.port, &GPIO_InitStructure);
  GPIO_InitStructure.GPIO_Pin   = i2c-> ; GPIO_Init(i2c->pin_sda.port, &GPIO_InitStructure);
  GPIO_PinAFConfig(i2c->pin_scl.port, i2c->pin_scl.source, i2c->pin_scl.altf) ;
  GPIO_PinAFConfig(i2c->pin_sda.port, i2c->pin_sda.source, i2c->pin_sda.altf) ;

Sometime, after the call of I2C_GPIO_config the I2C1.SR2.BUSY bit is set (With I2C peripheral disabled)
Ok the pinsa are already set to i2c alternate function and I can skip this config when not exit fom reset
But why the I2C peripheral regs are changed with peripheral disabled ?
The busy flag can be cleared only generting an I2C stop sequence.
I have tried to send a STOP condition but the busy is always set