|
|
View previous topic :: View next topic |
Author |
Message |
theMagni
Joined: 21 May 2004 Posts: 48 Location: Victoria, BC
|
16F88 & Comparators |
Posted: Mon Jan 10, 2005 6:39 pm |
|
|
Hello, forum.
I'm using the 16F88 and CCS compiler versions 3.214 / 3.191. (I know, pain in a jar, but hey, what else can I do?)
Is there a way to use just one comparator, or does enabling the comparator module with the internal reference voltage require two pins? That doesn't make any sense at all to me, but I've learned to discard all common sense when talking about embedded design. ;) Pins on this chip are at a premium, and I'd hate to have to commit three pins jus to use the A/D converter and the comparator.
Unfortunately, I don't have time to test this myself before the boards go out for printing.
Thanks for your help. _________________ In the 90's, I promised myself I'd never use a so-called "smiley icon". I hate what I've become. ;) |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Jan 10, 2005 7:22 pm |
|
|
It looks similar to the 16F628. I have one design with the 16F628
that uses one comparator. The analog signal comes in on the
RA1 (AN1) pin. The RA2 (AN2) pin has Vref on it, and it's
internally routed to the + pin of Comparator 2. The RA2 pin
is left unconnected on the board. You can't use it for anything else.
RA0 and RA3 can be used for digital i/o.
Here is the setup code:
Code: |
output_float(BAT_LEVEL_PIN_A1); // Input -- Comparator Vin- input
output_float(VREF_PIN_A2); // I/O -- Comp. Vin+ input, and Vref output
// Leave the comparator turned on all the time. (Comparator #2)
setup_comparator(NC_NC_A1_A2);
// Turn on the Vref generator. Vref goes to the Vin+ comp. input on pin A2.
setup_vref(VREF_LOW | VREF_A2 | LOBAT_VREF_LOW_THRESHOLD); |
I haven't tested this with a 16F88, so that's up to you.
Also, you should look at the assembly language listing (.LST file)
to confirm that setup_vref() and setup_comparator() work properly
with your version of the compiler. |
|
|
|
|
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
|