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

12F675 Vref

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



Joined: 15 May 2005
Posts: 11

View user's profile Send private message

12F675 Vref
PostPosted: Fri Jun 17, 2005 11:38 am     Reply with quote

Hello,

I am trying to measure a battery voltage with 12F675, and considering to
supply 2.5 v to Vref pin (GPO1)

Could someone explain me how to use setup_adc_ports() for my case?

I looked into the header file, but couldn't find right one for me.

Thanks a lot in advance
Dong

// Constants used in SETUP_ADC_PORTS() are:
#define sAN0 1 //| GP0
#define sAN1 2 //| GP1
#define sAN2 4 //| GP2
#define sAN3 8 //| GP4
#define NO_ANALOGS 0 // None
#define AN0_ANALOG 1 //!old only provided for compatibility
#define AN1_ANALOG 2 //!old only provided for compatibility
#define AN2_ANALOG 4 //!old only provided for compatibility
#define AN3_ANALOG 8 //!old only provided for compatibility
#define ALL_ANALOG 7 //!old only provided for compatibility

// The following may be OR'ed in with the above using |
#define VSS_VDD 0x0000 //| Range 0-Vdd
#define VSS_VREF 0x4000 //| Range 0-Vref
cmdrdan



Joined: 08 Apr 2005
Posts: 25
Location: Washington

View user's profile Send private message

PostPosted: Fri Jun 17, 2005 1:31 pm     Reply with quote

Dong --

setup_adc_ports(AN0_ANALOG | VSS_VREF) will give you one analog input on AN0, and enable you to use an external reference on AN1. To get more analog inputs, simply OR them into the setup statement, i.e. (AN0_ANALOG | AN2_ANALOG | AN3_ANALOG).

Make sure that you set up the right ADC clock rate with setup_adc(), and turn off the comparators with setup_comparator(NC_NC). Use #device ADC=8 or ADC=10, at the beginning of the program to determine 8- or 10-bit conversions.

Hope this helps....

Dan
dongseong



Joined: 15 May 2005
Posts: 11

View user's profile Send private message

Thanks!
PostPosted: Fri Jun 17, 2005 2:45 pm     Reply with quote

Thanks for an excellent explanation.

Dong
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