View previous topic :: View next topic |
Author |
Message |
guest Guest
|
PIC16F819 Analog Input Problems |
Posted: Thu Apr 28, 2005 11:56 am |
|
|
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 |
Posted: Thu Apr 28, 2005 12:03 pm |
|
|
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
|
|
Posted: Thu Apr 28, 2005 12:03 pm |
|
|
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 |
Posted: Thu Apr 28, 2005 12:05 pm |
|
|
#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
|
|
Posted: Thu Apr 28, 2005 12:27 pm |
|
|
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 |
Posted: Thu Apr 28, 2005 12:35 pm |
|
|
My bad. I completely read that data sheet wrong. Looks like it is time for some 'engineering' around this issue.
Thanks. |
|
|
|