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 support@ccsinfo.com

How to use two ADC inputs? [Solved]

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



Joined: 04 May 2011
Posts: 2

View user's profile Send private message

How to use two ADC inputs? [Solved]
PostPosted: Wed May 04, 2011 7:49 am     Reply with quote

Hello,

I have problem about using two different adc inputs. I dont know how to sepret it, i need to read value from one input, and after that from other one. But with this code:
Code:
 int a,b;

void main()
{

   setup_adc_ports(ALL_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   
   



   // TODO: USER CODE!!
   
    while(1)
   {
      set_adc_channel(2);   
      a = read_adc();
      set_adc_channel(3);
      b = read_adc();
      output_b(a);
      output_c(b);
   }

}


I have problem what two values comes together.
It will be great if anyone can help.
thanks
UnLiMiTeD!!!



Joined: 04 May 2011
Posts: 2

View user's profile Send private message

PostPosted: Wed May 04, 2011 7:57 am     Reply with quote

I solve the problem, its need just to put delay here is the code
Code:
#use delay(clock=4000000)


int a,b;

void main()
{

   setup_adc_ports(ALL_ANALOG);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_spi(SPI_SS_DISABLED);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   
   



   // TODO: USER CODE!!
   
    while(1)
   {
      set_adc_channel(2);
      delay_us(20);
      a = read_adc();
      set_adc_channel(3);
      delay_us(20);
      b = read_adc();
      output_b(a);
      output_c(b);
   }

}
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