![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Guest
|
Easy ADC question, pic16f684 |
Posted: Wed Dec 16, 2009 6:39 pm |
|
|
I'm just wondering if my PIC will automatically set my selected ADC pins as ANALOG. The device file says the following:
Code: | // Constants used in SETUP_ADC_PORTS() are:
#define sAN0 1 //| A0
#define sAN1 2 //| A1
#define sAN2 4 //| A2
#define sAN3 8 //| A4
#define sAN4 16 //| C0
#define sAN5 32 //| C1
#define sAN6 64 //| C2
#define sAN7 128 //| C3
#define NO_ANALOGS 0 // None
#define ALL_ANALOG 255 // A0 A1 A2 A4 C0 C1 C2 C3 |
My code snippet is:
Code: |
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc_ports(sAN0 | sAN1 | sAN2 | sAN4 | sAN5 | sAN6 | VSS_VDD);
set_adc_channel(2);
delay_us(20);
adc=read_adc();
LPOT=128+adc; |
I want all of my chosen adc ports to be analog instead of digital. My question is whether or not my pic will automatically set them as analog inputs? If I add "ALL_ANALOG" to the "setup_adc" line, will it set my chosen pins as ANALOG, or every adc pin on the entire pic, whether or not I choose them? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 16, 2009 7:27 pm |
|
|
Quote: | I want all of my chosen adc ports to be analog instead of digital |
Yes, you are selecting pins to be configured as analog, when you
call that function.
Quote: |
If I add "ALL_ANALOG" to the "setup_adc" line, will it set my chosen pins
as ANALOG, or every adc pin on the entire pic, whether or not I choose
them?
|
All pins on the chip that can be analog will be made analog. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Wed Dec 16, 2009 7:33 pm |
|
|
Thanks for the prompt response PCM, I didn't want to power my pic on with 3v going into each analog pin until I was sure, I've fried chips before because of this kind of thing.
Cheers! |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Thu Dec 17, 2009 12:18 pm |
|
|
I have another question reguarding the PIC16F684. I've programmed pins C3,C4,C5,A3,A4,A5 as blinking LED outputs, but I get strange results from A3 and A4. All of the other pins work perfectly. Pin A3 gives me a constant dim LED, and A4 gives me a constant BRIGHT LED. Pin A3 is also MCLR, but I've fused MCLR in my code.
Is there something I could be missing or forgetting to do? I can post the code if requested.
Thanks! |
|
![](templates/subSilver/images/spacer.gif) |
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Thu Dec 17, 2009 1:12 pm |
|
|
Anonymous wrote: | I have another question reguarding the PIC16F684. I've programmed pins C3,C4,C5,A3,A4,A5 as blinking LED outputs, but I get strange results from A3 and A4. All of the other pins work perfectly. Pin A3 gives me a constant dim LED, and A4 gives me a constant BRIGHT LED. Pin A3 is also MCLR, but I've fused MCLR in my code.
Is there something I could be missing or forgetting to do? I can post the code if requested.
Thanks! |
I don't have the datasheet for the 684 downloaded but you have to make sure that A3 and A4 are not open-collector outputs in which case you need a pullup resistor to Vdd to make it work. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 17, 2009 1:19 pm |
|
|
Look in the Device Overview section of the 16F684 data sheet.
Look at this table:
Quote: | TABLE 1-1: PIC16F684 PINOUT DESCRIPTION |
It lists the restrictions on the pins.
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010214
Some pins may not be i/o. They may be listed as input only.
Other pins may have a dual use that is defined by a fuse setting.
For example, to use oscillator pins as i/o when using the internal
oscillator, you must use the INTRC_IO fuse instead of just INTRC. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|