Anyone knows how to add two channels (CHS2 and CHS1 or CHS0)?
Using PIC18f1220
I have connected one input to AN4/RB0 pin(8) using CHS2 (bit 010) which is working good, but I want to add another input e.g. on AN5/RB1 pin(9).I have study the datasheet and have tried but unfortunately couldn’t able to do.
Any idea or can do for me please.
what I have done A/D code
ADCON1 =0x6F; //all IO are digital or 0b01101111 in binary on PORT A
TRISA = 0b00100000; //sets PORTA
PORTA = 0b00000000; //turns off PORTA outputs
TRISB = 0b01000001; //sets PORTB as all outputs
PORTB = 0b00000000; //turns off PORTB outputs, good start position
ADCON0bits.CHS2=1; //read port RB0
ADCON0bits.ADON = 1; //turn on A/D
ADCON2 = 0b10000000; //right justified, acquisition times are ok at 0 with 31kHz on PORT B
while (1)
{
ADCON0bits.GO = 1;
king regrads
Using PIC18f1220
I have connected one input to AN4/RB0 pin(8) using CHS2 (bit 010) which is working good, but I want to add another input e.g. on AN5/RB1 pin(9).I have study the datasheet and have tried but unfortunately couldn’t able to do.
Any idea or can do for me please.
what I have done A/D code
ADCON1 =0x6F; //all IO are digital or 0b01101111 in binary on PORT A
TRISA = 0b00100000; //sets PORTA
PORTA = 0b00000000; //turns off PORTA outputs
TRISB = 0b01000001; //sets PORTB as all outputs
PORTB = 0b00000000; //turns off PORTB outputs, good start position
ADCON0bits.CHS2=1; //read port RB0
ADCON0bits.ADON = 1; //turn on A/D
ADCON2 = 0b10000000; //right justified, acquisition times are ok at 0 with 31kHz on PORT B
while (1)
{
ADCON0bits.GO = 1;
king regrads