AnsweredAssumed Answered

STM32L0 ADC clock source and CubeMX

Question asked by Ancaritha on Jan 18, 2018
Latest reply on Feb 28, 2018 by cctt

Hi everyone!  I'm using an L071CBTx and I'm trying to figure out how to change the ADCs clock source using CubeMX.  According to the reference manual, "the ADC can be derived either from the APB clock or the HSI16 clock".  I can't figure out how to change it to anything other than the HSI clock.  The Clock configuration page of CubeMX has the source always coming from the HSI RC with no way to change it (other than the divider).  I'm using version CubeMX 4.22.1 and framework 1.9.0

 

Since I couldn't figure it out in CubeMX, I figured I would go manipulate the code directly... and can't figure it out there either.  I referenced an L4 project I have, and the following code gets generated in the clock setup: 

 

PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_I2C1 | RCC_PERIPHCLK_I2C2
| RCC_PERIPHCLK_USB | RCC_PERIPHCLK_ADC;
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1;
PeriphClkInit.I2c2ClockSelection = RCC_I2C2CLKSOURCE_PCLK1;
PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI1;
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSE;
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;
PeriphClkInit.PLLSAI1.PLLSAI1N = 12;
PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV2;
PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV4;
PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV4;
PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK | RCC_PLLSAI1_ADC1CLK;

 

I then tried to look up matching (or similar) defines in my L0 framework and there was nothing that had ADC selection or source in the name.... So how exactly do you change the ADC clock to be from the APB clock?

 

Thanks!

Outcomes