<font face="Courier New" size=-1>I am trying to read from two a/d channels on my 16F877. I am using the standard inbuilt read_adc() function. I set the channel then delay for 100ms before i take the reading BUT I can not read both channels within 1 program (both channels work if only 1 is being read within the program)
Has anyone got any suggestions as to errors I may have made.
I am using the PCM 3.023 compiler I have added the setup and read sections of my code below
set_adc_channel(1);
delay_ms(100);
adc=read_adc();</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12931
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
Re: reading two a/d channels
Posted: Fri Mar 21, 2003 2:57 pm
:=<font face="Courier New" size=-1>I am trying to read from two a/d channels on my 16F877. I am using the standard inbuilt read_adc() function. I set the channel then delay for 100ms before i take the reading BUT I can not read both channels within 1 program (both channels work if only 1 is being read within the program)
:=
:=Has anyone got any suggestions as to errors I may have made.
:=
:=I am using the PCM 3.023 compiler I have added the setup and read sections of my code below
:=
:=thanks
:=
:=chris
:=
:=
:=#Device ADC=10
:=
:= setup_adc_ports(ALL_ANALOG);
:= setup_adc(ADC_CLOCK_internal);
:= setup_spi(FALSE);
:= setup_psp(PSP_DISABLED);
:= setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
:= setup_timer_1(T1_DISABLED);
:= setup_timer_2(T2_DISABLED,0,1);
:= setup_ccp1(CCP_OFF);
:= setup_ccp2(CCP_OFF);
:=
:= set_adc_channel(0);
:= delay_ms(100);
:= adc=read_adc();
:=
:= set_adc_channel(1);
:= delay_ms(100);
:= adc=read_adc();</font>
Ask CCS to provide you with a newer compiler version. Your code should work.
___________________________
This message was ported from CCS's old forum
Original Post ID: 12934
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum