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

PIC16F819 Analog Input Problems

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







PIC16F819 Analog Input Problems
PostPosted: Thu Apr 28, 2005 11:56 am     Reply with quote

Question:
I am using a PIC16F819 and programming using the CCS C software. I want to use all of my analog inputs (7). However, when I try to read AN6 and AN7, the value for AN4 is returned. No matter what I try this is what occurs. I am using an internal oscillator. Any suggestions?
Thanks.
guest
Guest







Additional Info
PostPosted: Thu Apr 28, 2005 12:03 pm     Reply with quote

More information:
I am using the code:

set_up_ADC(all_analogs);

however I see that this only allows for AN0-AN5, how can I change that to allow for the whole bank of analog inputs?
Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 28, 2005 12:03 pm     Reply with quote

Quote:
When I try to read AN6 and AN7, the value for AN4 is returned.

1. What is your compiler version ?

2. Post a small test program that shows the problem.

Be sure to post all of your #include statement, #use statements,
#fuses statement, and make it be a complete program with a main(),
so it can be compiled. (Don't just post code fragments).
guest
Guest







CODE
PostPosted: Thu Apr 28, 2005 12:05 pm     Reply with quote

#include <16F819.h>

#device ADC=8
#include <math.h>
#fuses NOWDT,NOPROTECT,NOLVP,PUT,INTRC_IO
#use delay(clock=8000000)
void main() {
setup_oscillator(OSC_8MHZ); //set INTRC to prescaler of 8MHz
set_TRIS_A(0xFF); //PORTA setup 0b11111111
set_TRIS_B(0x00); //PORTB setup 0b00000000
setup_ADC_ports(ALL_ANALOG);
setup_ADC(ADC_CLOCK_INTERNAL);
}

That is the section of code relating to this problem. All of the read analog part is workin fine.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 28, 2005 12:27 pm     Reply with quote

Quote:
I am using a PIC16F819 and programming using the CCS C
software. I want to use all of my analog inputs (7).

Look at the data sheet for the 16F819.

It only has 5 analog pins: AN0-AN4

Pins RA5, RA6 and RA7 are digital i/o only.
guest
Guest







That would make sense
PostPosted: Thu Apr 28, 2005 12:35 pm     Reply with quote

My bad. I completely read that data sheet wrong. Looks like it is time for some 'engineering' around this issue.
Thanks.
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