AnsweredAssumed Answered

[Bug] CubeMX, STM32L4, ADC synchronuous clock settings

Question asked by Vinci on Nov 5, 2015

I know the title says bug, but it's more a suggestion than an actual bug report since the CubeMX code doesn't really "break" anything. I just spent the last three hours bug fixing my ADC code and hoping to find the actual sampling time of my ADC configuration...

The root of all the evil can be found [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32L4%20-%20ADC%20conversion%20time%20continuous%20mode%20%2b%20DMA&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3a//]here. The short version is that it took me some time to get used to the (at least for me) new ADC clock scheme with the option to switch between PLL/system and bus clock configurations. So when I setup the synchronous ADC clock in CubeMX and tested the new code it didn't work at first. The ADC clock was off by a factor of 2.

Re-checking every prescaler and clock option I came across a little sentence on page 430 in the reference manual:
"There are generally no constraints to be respected for the ratio between the ADC clock and the AHB clock except if some injected channels are programmed."

And this sentence is key. Because currently the CubeMX code does set JAUTO bit in the ADCs CFGR register which enables injectec conversions even if no injected channels are chosen within CubeMX. The JAUTO bit seems to automatically drop the ADC clock if the constraints on page 430 aren't met.

So I'd suggest for a further release to create code which doesn't set anything "injected" related if the user doesn't select the actual option.

Best regards