mousivand
Newbie level 4
Hi,
Happy new year
I want to use adc of stm32f051c8t6, but my code did not work correctly.
I use adc channel 0 to read the voltage, but the result is zero.
Can you please help me?
Thanks and Best Regards,
Happy new year
I want to use adc of stm32f051c8t6, but my code did not work correctly.
Code:
int main()
{
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN;
ADC1->CR |=ADC_CR_ADCAL;
while (ADC1->CR & ADC_CR_ADCAL);
ADC1->CR |=ADC_CR_ADEN;
ADC1->CHSELR |=ADC_CHSELR_CHSEL0;
RCC->APB1ENR |=RCC_APB1ENR_DACEN;
DAC->CR |=DAC_CR_EN1;
while(1)
{
ADC1->CR |= ADC_CR_ADSTART; /* Start the ADC conversion */
while (!(ADC1->ISR & ADC_ISR_EOC)); /* Wait end of conversion */
adc0 = ADC1->DR;
for(int j=0;j<2000000;j++)j=j;
}
}
I use adc channel 0 to read the voltage, but the result is zero.
Can you please help me?
Thanks and Best Regards,