|
|
View previous topic :: View next topic |
Author |
Message |
wave_man
Joined: 06 Jan 2005 Posts: 4 Location: spokane, WA
|
16F88 ADC setup |
Posted: Sun Feb 27, 2005 11:52 pm |
|
|
Hi all,
I am maybe using the wrong PIC for the job...
I, perhaps wrongly, assumed that I could configure the PIC16F88 for three analog inputs. I want to read AN0, AN1, and AN3, not necessarily at the same time, i.e. useconds are not critical. So, since it appears from the header that I can only configure for one ADC at a time, do I have to call a version of these statements every time I want a different channel?:
Code: | setup_adc_ports (sAN1);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(1);
setup_timer_0(RTCC_INTERNAL);
|
If so, how much time do the extra calls add during execution?
Thanks in advance for any help.
wave_man |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 28, 2005 12:48 am |
|
|
The section below is from the 16F88.H file. You can configure
the PIC with one or more analog pins by combining the sANx
constants with bitwise 'OR' symbols. Example:
setup_adc_ports(sAN0 | sAN1 | sAN3);
Then, select the individual channel that you want to do
an A/D conversion on, by using set_adc_channel();
Put in a short delay after changing the channel, before
you do the conversion with a read_adc() statement.
The example in the data sheet shows 20 usec, so just
do this for the delay: delay_us(20);
Code: | // Constants used in SETUP_ADC_PORTS() are:
#define sAN0 1 //| A0
#define sAN1 2 //| A1
#define sAN2 4 //| A2
#define sAN3 8 //| A3
#define sAN4 16 //| A4
#define sAN5 32 //| B6
#define sAN6 64 //| B7
#define NO_ANALOGS 0 // None |
|
|
|
wave_man
Joined: 06 Jan 2005 Posts: 4 Location: spokane, WA
|
|
Posted: Mon Feb 28, 2005 6:24 pm |
|
|
Thank you PCMP,
I was not sure you could do this, because the 877A offers explicit combinations in its .h file. Since the 88 .h file only had singles, I assumed there were no other choices.
Regards,
wave_man |
|
|
Ttelmah Guest
|
|
Posted: Tue Mar 01, 2005 8:25 am |
|
|
The reason for the difference, is in the chip. The 877 (for example), only allows specific combinations, so these are in the .h file. The F88, allows each ADC channel to be selected seperately, so gives the individual bits for these, and allows them to be ored together.
Best Wishes |
|
|
|
|
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
|