temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
if (UART1_Data_Ready()) { // If data is received,
UART1_Write(temp_res); // and send data via UART
}
PORTB = ~ Portb;
Delay_ms(2000);
} while(1);
}
So I am reading the value on the pin and send it by serial to computer. I change the value of the analog i/p using a pot.
But there are a problem facing me. The value that I read on terminal program swings and does not stabilize even if I disconnected the pot and connected the supply directly.
Actually I do not know if what I am facing is normal or not. I attach a photo captured from my terminal program, while receiving fixed analog i/p value from potentiometer.
The value displayed is not stable even if there is no change.
Actually I do not think that the compiler is involved in this problem. I have some doubts:
1-The defined variable in microC is unsigned int, and it should be max 2^10 -1 value because the limitation of the ADC. The terminal program has only 2 suitable formats to show the :twisted:ed int 10 data?
2-What is the refere i/p value nce voltage that the ADC compare the with? Does it compares with VCC?