bandi12
Newbie level 2
Hello. I am trying to measure voltage with this PIC, it has a 12 bit ADC because i got wrong voltages displayed i tried to display the ADC reading values and i got a surprise.
At 0V ADC is 64660 and goes up to 65510 meaning 2.1V from then suddenly drops to 0 and starts counting up to 1230 meaning 5V.
I used MikroC for PIC build in functions for ADC:
At 0V ADC is 64660 and goes up to 65510 meaning 2.1V from then suddenly drops to 0 and starts counting up to 1230 meaning 5V.
I used MikroC for PIC build in functions for ADC:
Code:
void main() {
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
TRISA = 0x7;
ANSELA = 0x7;
InitLCD();
ADC_Init();
while(1) {
char txt[10];
unsigned int adcRead = ADC_Get_Sample(2);
WordToStrWithZeros(adcRead, txt);
LCD_Out(1,2,txt);
Delay_ms(500);
}
}