View previous topic :: View next topic |
Author |
Message |
dongseong
Joined: 15 May 2005 Posts: 11
|
12F675 Vref |
Posted: Fri Jun 17, 2005 11:38 am |
|
|
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
|
|
Posted: Fri Jun 17, 2005 1:31 pm |
|
|
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
|
Thanks! |
Posted: Fri Jun 17, 2005 2:45 pm |
|
|
Thanks for an excellent explanation.
Dong |
|
|
|