2017-08-17 03:07 AM
Hi,
I'm using USB with SPL on an STM32F4 system.
If I do this :
while(1){
PWR_EnterUnderDriveSTOPMode(PWR_LowPowerRegulator_UnderDrive_ON, PWR_STOPEntry_WFI);
}
Then my system power consumption is 1.6mA.
But if I do this :
USBD_Init(&USB_OTG_dev,USB_OTG_FS_CORE_ID,&USR_desc, &USBD_CUSTOMHID_cb, &USR_cb);
while(1)
{
PWR_EnterUnderDriveSTOPMode(PWR_LowPowerRegulator_UnderDrive_ON, PWR_STOPEntry_WFI);
}
Then my system power consumption is 2.4mA.
It clearly appears that the USB initialisation increases power consumption in STOP mode.
I've noticed that this extra power consumption is due to 'GCCFG->PWDRWN' bit and USBCFG->FDMOD and SRPCAP bits.
After a USB initialisation, if I reset these bits to 0 thanks to the debugger, then I got back my 1.6mA in STOP mode.
But I'm not able to reset these bits programmatically.
USB_OTG_WRITE_REG32 (USB_OTG_dev.regs.GREGS->GUSBCFG, 0x00001440); <= does nothing (the value 0x00001440 is the same value as when I reset the SRPCAP and FDMOD bits manually with the debugger).
Any clue how to properly reset the USB to its default reset state ?
Any reason of this extra power consumption in STOP mode ?
Thanks.
Best regards,Vincent.
#stm32f4-usb-spl2017-08-18 10:42 AM
What could be worth a try is to set the PCGCCTL register's STPPCLK (it can also appear as STOPCLK) bit during STOP mode (it supposedly stops the USB PHY clocking), although this is no more than an initial guess.
2017-08-20 05:51 AM
I solved it by doing immediate register writes :
*((uint32_t*)0x50000038) = 0;
*((uint32_t*)0x5000000C) = 0x40001440; // Remove SRPCap *((uint32_t*)0x5000000C) = 0x00001440; // Remove FDMODNevertheless, this still doesn't explain the extra ~500µA power consumption if these bits are not cleared.