2013-09-18 03:55 AM
We have an STM32F37 running the SDADC perfectly. It also communicates via USB perfectly. Unfortunatly the SDADC stops working (gives reading of 0) when USB plug is pulled out. Also the SDADC stops working when USB plug is plugged in.
The only way round this is to call the ST routine: 'SDADC_DeInit' and reinitialise the SDADC. Has anybody come across this problem and knows a solution? The USB code is based on the ST code Thanks Rob2013-10-09 08:48 AM
Problem is in rewriting SDADC clock prescaler SDPRE[4:0] in RCC_CFGR register by USB library. SDPRE[4:0] is rewritten during USB plug/unplug.
Explanation:In USB library examples, there are systematically enter in low-power mode, when USB is in suspend mode. During unplug, since there is no USB traffic, the STM32 will automatically enter in STOP mode, and when USB is plugged again we will exit from STOP mode and reinitialize the clocks using SystemInit() (in function chain: Resume_Init() -> Leave_LowPowerMode() ).Solution:In the function Leave_LowPowerMode() do not call SystemInit() function but reinitialize only the PLL clocks and not re-initialize other RCC parts (modify Leave_LowPowerMode function). Then USB + SDADC will work fine during USB plug/unplug. Regards Igor