2016-11-02 01:25 AM
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 byI2C1Reinit():
=============================================void I2C1Reinit(void)
{ __disable_irq(); /////////////////////// I2C1 shut down I2C1->CR1 &= ~I2C_CR1_PE; while (I2C1->CR1 & I2C_CR1_PE) continue; RCC->APB1RSTR |= RCC_APB1RSTR_I2C1RST; Delay(10); // small delay RCC->APB1RSTR &= ~RCC_APB1RSTR_I2C1RST; 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); NVIC_EnableIRQ(I2C1_IRQn); __enable_irq();}=============================================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.2016-11-17 08:35 AM
Hello,
I recommned you to check the I2C example under the STM32F0xx_StdPeriph library, and compare it with your code and configuration to identify what is wrong in your case:STM32F0xx_StdPeriph_Lib_V1.5.0\Projects\STM32F0xx_StdPeriph_Examples\I2CRegards