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 CCS Technical Support

18F4620 and AN3

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



Joined: 11 Sep 2003
Posts: 51
Location: New Zealand

View user's profile Send private message

18F4620 and AN3
PostPosted: Tue Apr 29, 2008 6:50 pm     Reply with quote

Hi ALl,

I have been attempting to complete a design using AN0,1,2 and 3.
I have the following setup:
Code:

   setup_adc_ports(AN0_TO_AN3|VSS_VDD);//AN0
   setup_adc(ADC_CLOCK_DIV_32);
   setup_comparator (NC_NC_NC_NC);
   setup_vref (FALSE);


I am getting results from AN3 that look like the pin is set as a reference for the comparator. With nothing connected to the pin I read 4.8 volts on the AtoD.

Perhaps I have overlooked something in the setup or maybe someone has had a similar problem. I am using version 4.071 of the compiler.

Cheers

Mark
_________________
Life is too short to avoid asking questions
Matro
Guest







PostPosted: Wed Apr 30, 2008 9:15 am     Reply with quote

The setup_adc() should indicates an acquisition time.
For instance, for an acquisition time of 2.4µs :
Code:

   setup_adc_ports(AN0_TO_AN3|VSS_VDD);
   setup_adc(ADC_CLOCK_DIV_32|ADC_TAD_MUL_12);


Matro
Ttelmah
Guest







PostPosted: Wed Apr 30, 2008 9:34 am     Reply with quote

RA3, doesn't connect to the comparator Vref. RA2 does. If RA3 is high, check that the TRIS is set to 1 on this pin, and look carefully at your external wiring. If it is RA2, then check that the CVROE bit, is being cleared, by the setup Vref, and not just the Vref being disabled. So, just read it:
Code:

#byte CVRCON=0xFB5
#bit CVROE=CVRCON.6

if (CVROE==1) printf("This is the problem");


Or something similar, after disabling the Vref.

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