cancel
Showing results for 
Search instead for 
Did you mean: 

What's the difference between I2C SWRST and ABPxRSTR reset

AAl-H
Associate III

I have a bug in the I2C bus where sometimes a glitch causes the BUSY flag to be set

I found that the only ways to clear it is either by SWRST in I2C->CR1 or by resetting in RCC->ABP1RSTR->I2CxRSTR

My question is, is there any difference I should know about between these 2 types of resets or they're exactly the same?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions

In 'F4, I used both interchangeably and found no difference in their effect.

JW

View solution in original post

3 REPLIES 3

In 'F4, I used both interchangeably and found no difference in their effect.

JW

Thank you for your response

MVele.1
Associate II

There is one difference from MCU point of view:

The code below does not have any effect. The peripheral *) is not reseat and retain its configured values.

 __HAL_RCC_I2C1_CLK_DISABLE();
I2C1->CR1 |= I2C_CR1_SWRST;
I2C1->CR1 &= ~I2C_CR1_SWRST;
__HAL_RCC_I2C1_CLK_ENABLE();

*) Normally the peripheral should not be accessed with clock disabled, I did not get exact answers what is happening "inside", but debugger shows me zeroes during SFR reading.

The code below does have effect. The peripheral is reset to its default values.

  __HAL_RCC_I2C1_CLK_DISABLE();
  __HAL_RCC_I2C1_FORCE_RESET();
  __HAL_RCC_I2C1_RELEASE_RESET();
  __HAL_RCC_I2C1_CLK_ENABLE();

There can be another scenarios where using SWRST is needed, e.g. strong access control via MPU. At least for STM32F205/7 there could be explicitely stated that registers are reset too. It was a surprise for me, I did not expect duplication of __HAL_RCC_I2C1_FORCE_RESET(). My understanding was that only I2C internal state machine is reset.