AnsweredAssumed Answered

How to have a good precision of ADC on STM32F103C8?

Question asked by Carter Lee on Oct 23, 2017
Latest reply on Oct 23, 2017 by KIC8462852 EPIC204278916

Hi.

Now I'm trying to implement the ADC on the STM32F103C8.

but I came across some problem when I voltage leveling test.

 

The code is here 
x = getPot()*3.3/4095; //get analog value and convert to volts, 12bit ADC
if(x < 2.2)
{
GPIO_SetBits(GPIOA, GPIO_Pin_4);
GPIO_SetBits(GPIOA, GPIO_Pin_5);
GPIO_ResetBits(GPIOA, GPIO_Pin_6);
GPIO_SetBits(GPIOA, GPIO_Pin_7);
alram = 1;
}
else
{
GPIO_SetBits(GPIOA, GPIO_Pin_4);
GPIO_SetBits(GPIOA, GPIO_Pin_5);
GPIO_SetBits(GPIOA, GPIO_Pin_6);
GPIO_SetBits(GPIOA, GPIO_Pin_7);
alram = 0;
}

 

the below is what I got the outputs from ports.

 

 

 

As you can see that above image, when I set 2.2v to the ADC then the output is such a mess.

Is there any good way to get a clean operation?

Outcomes