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

input and output pin problem in port A

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



Joined: 03 Oct 2012
Posts: 242
Location: chennai

View user's profile Send private message

input and output pin problem in port A
PostPosted: Mon Jul 13, 2015 11:35 pm     Reply with quote

Controller: 18LF2520, Internal Oscillator: 1Mhz.

I have connected a button at PIN A1. And analog input at PIN A2.

I tried using the below code to capture the analog sigal at pin A2,
Code:
   setup_adc(  ADC_CLOCK_INTERNAL  );
//   setup_adc_ports( ALL_ANALOG );
   setup_adc_ports(AN0_TO_AN2);
   set_adc_channel(2);


When i press the button, there is no action at all. Is it configuring the pin A0 to A2?? Please help.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Mon Jul 13, 2015 11:57 pm     Reply with quote

What you post, is not enough for us to have any idea.

The ADC_CLOCK_INTERNAL, is _not_ recommended on your chip at clock frequencies above 1MHz. This though will only make the values less accurate.

But you give us no data. What is generating the voltage on A2?.
How does the code then read this?.

There is then the big problem. You are trying to use A1 as a logic input, but have it set as an analog input.

You show setup for the ADC, but nothing using it, so nothing will happen. Sounds as if your code is doing exactly what it is programmed to do....
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