2015-01-21 05:09 AM
Hi all,
i'm using STM32F407/F417 with 12MHz crystal, and i would like to save power as possible, because i need to run it on batteries, i need to have USB connected, i read in manual that i could underclock ... please could somebody direct me how to do it and to not loose usb connection ? so exactly: at one moment i need full swing and other moment i need to save power and it's not required to have fast execution, thanks for all replies ...2015-01-23 08:19 AM
Hi all,
so i tried my idea: RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_HSI) {;} results: usb link seems to be ''not lost'' but it's unresponsive, maybe too fast IRQs on USB ? first is not replied and comes next ... does anybody has an idea what can i try ? is there some possibility to setup USB frame frequency during linked USB ? EDIT: measured currents ... measurement of the whole device: stm32f407 not booted ... (BOOT0 pin) ... 144mA (whole device) stm32f407 booted and USB connected FS core ... 255mA RCC_SW_HSI ... 214mA but USB unresponsive so stm32f407 takes at least 111mA and underclocking can save 40mA ...2015-01-24 03:52 AM
for those who are interested:
so i added : RCC->CFGR &= (uint32_t)((uint32_t)~(RCC_CFGR_SW)); while ((RCC->CFGR & (uint32_t)RCC_CFGR_SWS ) != RCC_CFGR_SWS_HSI) {;} FLASH->ACR &= ~(FLASH_ACR_LATENCY_7WS); and i had to reinit USARTs due to recalculation BRR for debugging for new frequencies of APB, and i found that there is permanent IRQ without clearing flag: in Library 2.1.0 19-March-2012 in file usb_dcd_int.c: in DCD_HandleInEP_ISR: ep_intr = USB_OTG_ReadDevAllInEPItr(pdev); -- there is always zero, but this line is executed because IRQ came and some flag should be raised, so there is bug in Library - there is situation that is not fixed and based on this fact there is permanently called IRQ, raised flag is: EP1: DIEPINT: 00000080 (TXFE: Transmit FIFO empty ) and same situation is when stm32f407 is clocked normally at 168MHz and when ACM viewer on Host is closed and stm32 is trying to send data ... so i disabled in MSK this flag and stm32 reacts on sent data from Host to STM32 and STM32 is trying to send back reply but Host is not receiving ... so i think that's useful but there is still some bug in communication in direction STM32 -> Host CDC , when running at 16MHz HSI internal RC and 12MHz external crystal only for USB, if somebody knows please let me know how to debug & fix ... Kind regards,2015-01-26 07:03 AM
> in Library 2.1.0 19-March-2012 in file usb_dcd_int.c:
> .. > there is situation that is not fixed and based on this fact there is permanently called IRQ Discussed on this topic, > it should be prepared to run ''the job'' anytime after first ''the job'' How quickly should the ''job'' be responded? To save power on USB device, you may drop the USB connection into Suspend on the host side. But Resume takes a couple of 100ms.. Tsuneo