int16 value;
void main()
{
set_tris_a(0xff);
ENABLE_INTERRUPTS(GLOBAL);
setup_adc_ports(ALL_ANALOG); hoặc setup_adc_ports(an0);
setup_ADC(ADC_CLOCK_DIV_32);//tùy bạn
set_adc_channel(0);
while(1)
{
int t;
delay_ms(500); // mình nghĩ ko cần
value=read_adc();
Đây là một số thứ theo mình biết bạn dùng ADC 10 bit bạn khai báo value ở chế độ int16 thì hợp lý hơn.
|