2010-03-08 06:04 AM
use of RCC_APB2PeriphResetCmd()
2011-05-17 04:42 AM
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.
RCC_APB2Periph_AFIO, RCC_APB2Periph_GPIOA, RCC_APB2Periph_GPIOB, RCC_APB2Periph_GPIOC, RCC_APB2Periph_GPIOD, RCC_APB2Periph_GPIOE, RCC_APB2Periph_GPIOF, RCC_APB2Periph_GPIOG, RCC_APB2Periph_ADC1, RCC_APB2Periph_ADC2, RCC_APB2Periph_TIM1, RCC_APB2Periph_SPI1, RCC_APB2Periph_TIM8, RCC_APB2Periph_USART1, RCC_APB2Periph_ADC32011-05-17 04:42 AM
2011-05-17 04:42 AM
Hi,
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.2011-05-17 04:42 AM
Hi,
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, lowpower2011-05-17 04:42 AM
>>So I still do not understand reason of RCC_APB2PeriphResetCmd() function. Could some one clarify?
To get it into a KNOWN/VALID state instead of some RANDOM/INVALID/ARBITRARY one, once the clocks are running. -Clive2011-05-17 04:42 AM
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.2011-05-17 04:42 AM
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.2011-05-17 04:42 AM
Thanks for replay for everyone. Now is much more clear.
But it is really shame that such function and functionality is not documented at all, or maybe I can not find out(?) Regards2011-05-17 04:42 AM
Not deep enough search :)
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...