CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

reading two a/d channels

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chris_1982
Guest







reading two a/d channels
PostPosted: Fri Mar 21, 2003 2:15 pm     Reply with quote

<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>
___________________________
This message was ported from CCS's old forum
Original Post ID: 12931
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: reading two a/d channels
PostPosted: Fri Mar 21, 2003 2:57 pm     Reply with quote

:=<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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group