# how to read all channel of adc of PIC controller using ccs c compiler

Status
Not open for further replies.

##### Junior Member level 1
hello,
can't we use all adc channel of pic in one program using ccs c compiler, when i wrote a code to read one channel it works fine, but when read other channel cross talk like thing happens i don't why.....
does anybody faced same problem and solved..

#### andre_teprom

##### Super Moderator
Staff member
Better you post the code section related to A/D acquisition.
This way is impossible know what is happening.

+++

##### Junior Member level 1
this is my code

#include <18F458.h>
#fuses HS,NOPROTECT,NOLVP,NOWDT
#use delay(clock=20000000)

void main()
{
int16 buffer[8],temp_res,pressure_res,level_res;

lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"welcome");
lcd_gotoxy(1,2);

while(1)
{
temp_res = 0;
buffer[0] = temp_res;
lcd_gotoxy(1,1);
printf(lcd_putc,"Temp:%ld ",temp_res);
delay_ms(1000);

buffer[0] = pressure_res;
lcd_gotoxy(1,2);
printf(lcd_putc,"Pressure: %ld",pressure_res);
delay_ms(1000);

level_res = level_res - 125;
buffer[0] = level_res;
lcd_gotoxy(10,1);
printf(lcd_putc,"Lvl:%ld ",level_res);
delay_ms(1000);

}
}

when i comment other two adc routine the temperature one works fine but while three at a time creates cross talk

#### hussain_kiet

##### Full Member level 5
what do you mean by cross talk.?
what exactly do you see..?

---------- Post added at 08:52 ---------- Previous post was at 08:44 ----------

I am not sure......., but the problem might be the second adc value overwrites on the first value as you print the first one on

lcd_gotoxy(1,1);

and second one on

lcd_gotoxy(1,2);
try to shift the second one's location ...

##### Junior Member level 1
but there is delay of 1 sec so even if it overwrites will not matter....

cross talk means when i try to change temperature by heating it the value of level input changes and if level changed temperature changes even if sensor is untouched...

#### hussain_kiet

##### Full Member level 5
make sure that there is no hardware problem...
have you simulated this code...?

#### andre_teprom

##### Super Moderator
Staff member
comparing to a code I wrote using multichanel reading I note that is missing the following argument :

Code:
read_adc ( ADC_START_ONLY )   ;
Did you saw the set of examples at CCS instaled folder ?

+++

##### Junior Member level 1
hardware seems to be ok, i had this cross talk problem in simulation also....

ill try adding the suggested line and let you know.

thank you!

Status
Not open for further replies.