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

Trouble while using port F as ADC (18F6720)

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



Joined: 16 Sep 2003
Posts: 71
Location: Moers, Germany

View user's profile Send private message

Trouble while using port F as ADC (18F6720)
PostPosted: Mon Jan 19, 2004 4:03 am     Reply with quote

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

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

PostPosted: Mon Jan 19, 2004 6:59 am     Reply with quote

Did you make those pins inputs?
wedilo



Joined: 16 Sep 2003
Posts: 71
Location: Moers, Germany

View user's profile Send private message

PostPosted: Tue Jan 20, 2004 6:38 am     Reply with quote

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
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