View previous topic :: View next topic |
Author |
Message |
wedilo
Joined: 16 Sep 2003 Posts: 71 Location: Moers, Germany
|
Trouble while using port F as ADC (18F6720) |
Posted: Mon Jan 19, 2004 4:03 am |
|
|
Hello,
I'm using a PIC 18F6720 with CCS-Compiler V 3.184.
Has anyone experience in using port F as ADC?
I tried this:
Code: | setup_adc_ports(ANALOG_AN0_TO_AN7) |
In the header file of the 6720 I find:
#define ANALOG_AN0_TO_AN7 0x07 // A0 A1 A2 A3 A5 F0 F1 F2
The first five pins working correctly, but F0, F1 and F2 are not working.
Is here anyone who know why?
73 Sven |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Jan 19, 2004 6:59 am |
|
|
Did you make those pins inputs? |
|
|
wedilo
Joined: 16 Sep 2003 Posts: 71 Location: Moers, Germany
|
|
Posted: Tue Jan 20, 2004 6:38 am |
|
|
Hello Mark,
Thanks for your reply.
Sorry, but I can't understand your message.
Did you mean that I maybe use port F for i/o operations?
If yes then I can say 'No, I don't'
Please have a look to the code:
Sorry, this is code by a friend of mine and only a snippet of the complete project.
Code: |
void main() {
setup_adc_ports(ANALOG_AN0_TO_AN7)
set_tris_F(0xff);
setup_adc(ADC_CLOCK_INTERNAL);
...
Measure();
...
void Measure() {
int ni,nm;
long int res1;
for (ni=0;ni<=7;ni++) {
res1=0;
SET_ADC_CHANNEL(ni);
delay_ms(10);
for (nm=1;nm<=5;nm++) {
U[ni] = READ_ADC();
res1 +=U[ni];
}
U[ni]=((float)res1 / 5);
printf("U Channel %U = %U\r\n",ni,U[ni]);
}
}
}
|
Yes, that's it. I copied it from the complete code and hope I havn't forgotten something.
The Channels 0...4 are still working, only 5...7 not.
73 Sven |
|
|
|