View previous topic :: View next topic |
Author |
Message |
hemnath
Joined: 03 Oct 2012 Posts: 242 Location: chennai
|
input and output pin problem in port A |
Posted: Mon Jul 13, 2015 11:35 pm |
|
|
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: 19520
|
|
Posted: Mon Jul 13, 2015 11:57 pm |
|
|
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.... |
|
|
|