AD converter module starts conversion if the Go bit is set, if this bit is clear then conversion is done. You must check this.if(GO_bit==1)
AD converter module starts conversion if the Go bit is set, if this bit is clear then conversion is done. You must check this.if(GO_bit==1)
To be sure that result will be contain both registers information concatenated to 16 bit integer is better to add casting operator :
wlevel = ((int)((ADRESH << 8) + ADRESL));
where wlevel should be declared as int. If you want display result as float you better use different float-type variable for it.
wlevel is declared as int;
trisa=0x3f;
trisb=0x00;portb=0x00;
trisc=0xff;
trisd=0xff;
trise=0x07;
InitTimer0();
cmcon=0x07;
ADCON0=0b11000001;
ADCON1=0b10001110;also i changed 7th bit in both 0 & 1
delay_ms(2000);
GO_bit=1;delay_ms(1);
if(GO_bit==1){ wlevel = ((int)((ADRESH << 8) + ADRESL));}
When ADON = 1:AD converter module starts conversion if the Go bit is set, if this bit is clear then conversion is done. You must check this.
You set this bit already by initializing ADCON0 register (it is bit0 in this register). This bit will stay on until you disable it. Only thing you need for starting conversion is setting the GO_bit (bit2 in same register). If AD conversion is done GO_bit is cleared automatically by MCU.should i check it?
ive solved it i usedWhen ADON = 1:
1 = A/D conversion in progress (setting this bit starts the A/D conversion which is automatically
cleared by hardware when the A/D conversion is complete)i think its cleared by hardware as in datasheet or should i check it?
thanks trebla for ur concern and your timeive solved it i used
wlevel=ADC_Get_Sample(0);
instead of adc_read
by Duane Benson
by Duane Benson
by Jake Hertz
by Duane Benson