2013-02-05 06:05 AM
I'm trying to understand how below function call from usb_bsp.c source file works:
RCC_APB1PeriphResetCmd( RCC_APB1Periph_PWR, ENABLE );This is from Reference Manual:5.3.8 RCC APB1 peripheral reset register (RCC_APB1RSTR)Bit 28 PWRRST: Power interface reset
Set and cleared by software.
0: does not reset the power interface
1: resets the power interface
1. What is Power Interface? 2. Why should it be reset?3. ENABLE means that bit is written to 1. Does it mean that reset on Power Interface will stay asserted all the time until SW writes this bit to 0?
2013-02-05 07:24 AM
The PWR section typically controls the backup domain in your unspecified part, the unit that is powered independently by VBAT.
You might want to reset it to get it into an KNOWN state, as it operates in a different domain than the rest of the chip, and doesn't watch NRST is the same way. If it isn't operating correctly or as expected, you might want to reset it. A reset is achieved by enabling, and then disabling RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE); RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, DISABLE); You could perhaps hold it in reset, but I'm not sure that serves a useful purpose. It would make using the peripheral difficult, like not enabling the clock would.2013-02-06 12:29 AM
Fully understand and agree with you.
I searched over manual and found a few mentions of this clock. Also I looked at the SPL clock reset functions and have seen usage of the Reset register. The below code is taken from USB example:STM32_USB-Host-Device_Lib_V2.1.0/Project/USB_Device_Examples/HID/src/usb_bsp.cLine 246: /* enable the PWR clock */ RCC_APB1PeriphResetCmd(RCC_APB1Periph_PWR, ENABLE);There is no DISABLE anywhere. I assume it is a bug but not critical as example does not use VBAT.2013-02-06 03:18 AM
As per the comment they are trying to Enable the Clock, not Reset the peripheral, the wrong function is being used.