cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F37, SDADC stops working when USB connected/disconnected

robcrann
Associate II
Posted on September 18, 2013 at 12:55

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

http://www.st.com/st-web-ui/static/active/en/st_prod_software_internet/resource/technical/software/firmware/stsw-stm32081.zip

Thanks

Rob
1 REPLY 1
Igor Cesko
ST Employee
Posted on October 09, 2013 at 17:48

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