# STM32F4 - RCC reset register

I can't understand what's the job of RCC_xxPeriphResetCmd() function in the stm32f4xx-rcc driver? in fact the thing that i can't realize is what happens to a peripheral when we reset it (by setting it's relative bit in the RCC AHBx(or APBx) peripheral reset register) ?

for example for AHB1 Peripheral :

the register is :

and stm32f4xx-rcc driver function is :

void RCC_AHB1PeriphResetCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
{
/* Check the parameters */
assert_param(IS_RCC_AHB1_RESET_PERIPH(RCC_AHB1Periph));
assert_param(IS_FUNCTIONAL_STATE(NewState));

if (NewState != DISABLE)
{
RCC->AHB1RSTR |= RCC_AHB1Periph;
}
else
{
RCC->AHB1RSTR &= ~RCC_AHB1Periph;
}
}

• I would imagine resetting a peripheral is clearing it's registers to default values. – Eugene Sh. Oct 30 '18 at 19:35
• @EugeneSh. as i understand ,you say that the RCC unit, reset a peripheral to its default value by giving it some clock ? – Amin Oct 30 '18 at 19:41

The Peripheral Reset Registers should cause the peripheral's entire register set and internal state to be reset to power-on defaults. This means not just the registers that are exposed to the user, but also any internal registers, counters, or flags should be set as they would be when the device is initially powered on. However, this is not clearly specified in the datasheet or reference manual, which is unfortunate.

Some of the peripheral descriptions in the datasheet reference things that happen when the peripheral reset is activated, and this gives some insight into how deep the peripheral reset goes. Here's an example from the STM32F4xx reference manual:

GPIO port configuration lock register (GPIOx_LCKR) (x = A..I/J/K) This register is used to lock the configuration of the port bits when a correct write sequence is applied to bit 16 (LCKK). The value of bits [15:0] is used to lock the configuration of the GPIO. During the write sequence, the value of LCKR[15:0] must not change. When the LOCK sequence has been applied on a port bit, the value of this port bit can no longer be modified until the next MCU or peripheral reset.

This makes it clear that the peripheral reset can accomplish things that the user program can't otherwise do.