View previous topic :: View next topic |
Author |
Message |
kable Guest
|
port a |
Posted: Sat Jan 24, 2004 7:11 pm |
|
|
can someone please help me
i need to set up port a for a0 - a2 as analog and a3-a5 and e0-e2 as digital inputs
i cant get it to work.
can someone please tell me the ccs code to set the port this way? |
|
![](templates/subSilver/images/spacer.gif) |
kable Guest
|
|
Posted: Sat Jan 24, 2004 7:36 pm |
|
|
i was not clear on what i am doing, sorry,
i have a 16f877a
i want to use some inputs as listed above for analog voltage measurements and some as digital inputs.
do i need to put pull up resistors and have the buttons ground? currently i have the buttons switching a +5v to the pins.
someone please help me with setting this up.
please ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
wa822
Joined: 17 Dec 2003 Posts: 4 Location: London UK
|
Analogue & Digital |
Posted: Sun Jan 25, 2004 6:48 am |
|
|
The Microchip data sheet provides the information on what pins can be used for. It is a good idea to read this an much as time allows.
CMOS (PIC) Digital inputs have very high input impedance. They need to be pulled HIGH or LOW at all times. Otherwise they can cause all kinds of strange operation.
This includes oscillating at line frequency (50 / 60 Hz) or at any other frequency picked up. Also, the circuit can stop or start working when your hand comes near the board!
On this device, week pull-ups can be enabled on port B. If they are enabled, switches can be connected to 0V without using any resistors to Vdd.
Resistor values are not critical. 10k is a good value
Good luck _________________ Andrew White |
|
![](templates/subSilver/images/spacer.gif) |
Charlie U
Joined: 09 Sep 2003 Posts: 183 Location: Somewhere under water in the Great Lakes
|
Port A configuration |
Posted: Sun Jan 25, 2004 9:10 am |
|
|
Unfortunately, using A0 through A2 as analog inputs is not an available option. The only way you can have only 3 analog inputs is to configure the port with A0, A1, and A3 as analog inputs. All others will be digital I/O. Use the built in function for setting up the analog section with the proper parameter as follows:
#setup_adc_ports(RA0_RA1_RA3_ANALOG);
Refer to the device data sheet in section 11, and the device include file, PIC16F877A.h, and the compiler online help for additional information. |
|
![](templates/subSilver/images/spacer.gif) |
|