AnsweredAssumed Answered

I2C module hangs on STM32F030K6

Question asked by AlexP on Nov 2, 2016
Latest reply on Nov 17, 2016 by ForumSTM32.ForumSTM3
Hello all.
I've got a problem using I2C1 module on STM32F030K6 MCU. Everything works properly until I enter ESD exposure to the pcb. This leads to I2C hanging, but other parts of MCU continue working.
I tried to restart I2C after this event by I2C1Reinit():

void I2C1Reinit(void) 

    /////////////////////// I2C1 shut down
    I2C1->CR1 &= ~I2C_CR1_PE;
    while (I2C1->CR1 & I2C_CR1_PE) continue;

    Delay(10); // small delay
    I2C1->CR1 = 0;  
    I2C1->CR2 = 0;  
    I2C1->OAR1 = 0;
    I2C1->OAR2 = 0;
    I2C1->TIMINGR = 0;
    I2C1->TIMEOUTR = 0;
    I2C1->ICR |= 0x3F38;
    RCC->APB1ENR &= ~RCC_APB1ENR_I2C1EN; // disable peripheral clock I2C1

  //////////////////// I2C1 reinitialization

  // Configure RCC for I2C1 
  RCC->APB1ENR |= RCC_APB1ENR_I2C1EN; // Enable the peripheral clock I2C1 
  RCC->CFGR3 |= RCC_CFGR3_I2C1SW;     // Use SysClk for I2C CLK
  // Configure I2C1 
  I2C1->TIMINGR = (uint32_t)0x00805C89;        
  I2C1->CR1 = I2C_CR1_GCEN | 0xFE | I2C_CR1_PE;
  I2C1->OAR1 = (uint32_t)0x50;     
  I2C1->OAR1 |= I2C_OAR1_OA1EN;                
  I2C1->ICR |= 0x3F38;          
  // Configure IT 
  NVIC_SetPriority(I2C1_IRQn, 0);  

But all my attempts to reinit I2C were failed. After ESD event both of SDA and SCL lines are released ("1" state) and only the case to make I2C to work is power Off and then On.
Are there any ways to reanimate I2C by sw?
I appreciate any help. Thanks.