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

A/D Pin A5 always high?

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



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

A/D Pin A5 always high?
PostPosted: Thu Oct 06, 2005 7:05 am     Reply with quote

Hello,

when I run a Analog/Digital test on my PIC16F877A with the pins A0, A1, A2, A5 and pin A3 as Vref all works but pin A5. Pin A5 always gives 1023, no matter what voltage I put on it's line.

i use following the following code to initialize the AD ports:

Code:
setup_adc_ports(A_ANALOG_RA3_REF); //sets A0, A1, A2 and A5 to analog and A3 to Vref
setup_adc(ADC_CLOCK_DIV_32); // define clock settings


Since the other pins work I guess and the hardware on all ports is the same I think I forgot to initialize something in my software. But I cannot find anything on the Datasheet Confused

Can someone help me?
Ttelmah
Guest







PostPosted: Thu Oct 06, 2005 7:14 am     Reply with quote

Have you looked carefully at the pin diagrams. 'AN5', is not on pin 'A5', but on E0. AN4, is actually on pin A5. So you need to setlect the analog channel '4', to actually read a voltage on 'A5' (confusing...).

Best Wishes
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Thu Oct 06, 2005 7:29 am     Reply with quote

Ttelmah wrote:
Have you looked carefully at the pin diagrams. 'AN5', is not on pin 'A5', but on E0. AN4, is actually on pin A5. So you need to setlect the analog channel '4', to actually read a voltage on 'A5' (confusing...).


This did it! Thanks.

Now do I have another question: how do I define RA4, since RA5 is AN4?
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Thu Oct 06, 2005 9:01 am     Reply with quote

Foppie wrote:
Ttelmah wrote:
Have you looked carefully at the pin diagrams. 'AN5', is not on pin 'A5', but on E0. AN4, is actually on pin A5. So you need to setlect the analog channel '4', to actually read a voltage on 'A5' (confusing...).


This did it! Thanks.

Now do I have another question: how do I define RA4, since RA5 is AN4?


Define RA4 as what??????

Do you mean where is AN5? If so, its on E0.
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Fri Oct 07, 2005 12:44 am     Reply with quote

Mark wrote:
Define RA4 as what??????

Do you mean where is AN5? If so, its on E0.


I first defined pin RA5/AN4 as PIN_A5, but as Ttelmah said I should define it as PIN_A4. Now My question is, how should I define pin RA4/TOCKl (I first thaught I should define it as PIN_A4 but since that is another pin I don't know how to define it)?

P.S.
I do not use Timer0
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Oct 07, 2005 7:16 am     Reply with quote

NO! RA5 is PIN_A5! But RA5 is AN4. RA4 is PIN_A4, confused yet Razz
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Fri Oct 07, 2005 7:41 am     Reply with quote

Mark wrote:
NO! RA5 is PIN_A5! But RA5 is AN4. RA4 is PIN_A4, confused yet Razz

huh?

I first defined RA5/AN4 as PIN_A5 but that didn't work. Now I defined RA5/AN4 as PIN_A4 and it is working...

But now you say my non-working code should be working an dmy working code should not??? Shocked

I am getting very, very confused here Confused
(probably end-of-the-week meltdown....)

I will test it monday all over again and post my results...

thanks for your help!
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Fri Oct 07, 2005 7:58 am     Reply with quote

Ttelmah wrote:
Have you looked carefully at the pin diagrams. 'AN5', is not on pin 'A5', but on E0. AN4, is actually on pin A5. So you need to setlect the analog channel '4', to actually read a voltage on 'A5' (confusing...).

Best Wishes


RJ never said anything about defining something as PIN_A4. He said that RA5 (PIN_A4) is analog channel 4. When you set the adc channels, you do not use PIN_Ax. You use a number instead.
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Mon Oct 10, 2005 12:33 am     Reply with quote

Mark wrote:
RJ never said anything about defining something as PIN_A4. He said that RA5 (PIN_A4) is analog channel 4. When you set the adc channels, you do not use PIN_Ax. You use a number instead.

I finally understand now! Thank you very much
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