# Problem with adc of stm32f051

#### Mousivandhossein

Joined Dec 8, 2020
26
Hi,
Happy new year

I want to use adc of stm32f051c8t6, but my code did not work correctly.
Code:
int main()
{

RCC->APB1ENR |=RCC_APB1ENR_DACEN;
DAC->CR |=DAC_CR_EN1;

while(1)
{
for(int j=0;j<2000000;j++)j=j;
}
}
I use adc channel 0 to read the voltage, but the result is zero.

Thanks and Best Regards,

#### MrChips

Joined Oct 2, 2009
26,485
You do not say what toolset you are using.
You do not show all your #include statements.
You did not select which pins to be used as ADC inputs.
... for starters.