Posted on May 17, 2011 at 13:42 Hi Thanks for reply. But I still do not understand what you mean. What means enable/disable since name of function contain ''reset'': RCC_APB2PeriphResetCmd() and body: void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState) { (...) if (NewState != DISABLE) { RCC->APB2RSTR |= RCC_APB2Periph; } else { RCC->APB2RSTR &= ~RCC_APB2Periph; } } operate on APB2RSTR register, in RM0008this register is described: APB2 peripheral reset register. You claiming is disable/enable but for disable/enable is RCC_APB2PeriphClockCmd() what operate on RCC_APB2ENR what is enable register. So I still do not understand reason of RCC_APB2PeriphResetCmd() function. Could some one clarify? Best Regards
Look at the Clock Tree diagram (fig 8) and the System Architecture (figs 1 / 2 ) and you will see how the peripherals are connected to APB2. You can map / re-map them to STM32 pins but you will also want to enable or disable them. That's when you need ''RCC_APB2PeriphResetCmd( )''. You can enable / disable any of the pre-defined functions listed below.
In the reference manual it is explained in ''APB2 peripheral reset register'' subsection of RCC section: bit 0: No effect bit 1: Reset peripheral Regards, lowpower
Sorry if my reply confused you. RCC_APB2PeriphResetCmd is used to RESET a peripheral. RCC_APB2PeriphClockCmd is used to enable or disable the CLOCK to a peripheral.
RCC_APB2PeriphResetCmd(xxx, ENABLE); is like pressing the reset button
RCC_APB2PeriphResetCmd(xxx, DISABLE); is like releasing it again. You have to call both functions in this order to do a correct reset of the peripheral. Enabling or disabling the clocks does change the current consumption. It is like power on/off of your monitor. The state isn't changed by doing this. You can't only see the function in off-mode. Some peripheral have side effects on CLK enable/disable! So please check it in your case.
This is a pretty curious function. It would seem that you can get the peripheral in a known state simply by enabling and disabling the clock (this is called ''DeInit'' in the STM32 library). What is the difference between toggling the enable bit and toggling the reset bit? Do you really need to reset the peripheral after you enable to put it into a know state?
I suspect the answer is no. The reset function was put into the device by the designers as a hedge in case something didn't work right with the enable sequence or something else for device testing.
In Reference Manual, chapter 7 RCC, look for the registers (esp. RCC_APB2RSTR, RCC_APB1RSTR). In fact, Whatever_DeInit doesn't toggle clock, but the reset line. The peripheral is reset properly at power-on, but you may want to initialize it again without any side-effects if you changed the clock, if you want to change the mode of operation, if the peripheral got stuck for whatever reason...