AnsweredHot!PIC16F688 Comparator and VREF Connection

Author
IO
Starting Member
  • Total Posts : 71
  • Reward points : 0
  • Joined: 2011/01/08 11:45:44
  • Location: 0
  • Status: offline
2017/08/05 12:50:03 (permalink)
0

PIC16F688 Comparator and VREF Connection

The datasheet for the PIC16F688 does not say how the internal voltage reference is connected to the comparators - inverted or non-inverted inputs?
http://ww1.microchip.com/...n/DeviceDoc/41203E.pdf

Also, I would like to use only one comparator but I do not want the output on an external pin - I only need to see it in code, whether by an interrupt or by polling.
"One Independent Comparator CM<2:0> = 101" puts the output on an external pin.
And I do not want to waste a pin for the comparator output. Is it possible?

So, to sum up, I want to use a single comparator, with internal voltage reference, and process the comparator output in software.
Total I/O pins used: 1


Thanks.
#1
mbrowning
Caffeine Caffeine
  • Total Posts : 528
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: online
Re: PIC16F688 Comparator and VREF Connection 2017/08/05 14:15:37 (permalink) ☼ Best Answerby IO 2017/08/05 15:36:57
+2 (2)
seems like mode "Four Inputs Multiplexed to Two Comparators CM<2:0> = 010 is exactly what you want
 
and, by the way, cm=101 does not have an output. The only one with outputs is 110.
post edited by mbrowning - 2017/08/05 14:19:49

Mark
#2
IO
Starting Member
  • Total Posts : 71
  • Reward points : 0
  • Joined: 2011/01/08 11:45:44
  • Location: 0
  • Status: offline
Re: PIC16F688 Comparator and VREF Connection 2017/08/05 15:05:58 (permalink)
0
Ok, thank you. I overlooked the "From CVREF Module" signal at the diagram.
 
 Are these comparators open drain?

Attached Image(s)

#3
mbrowning
Caffeine Caffeine
  • Total Posts : 528
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: online
Re: PIC16F688 Comparator and VREF Connection 2017/08/05 16:32:26 (permalink)
+2 (2)
They are bits in the CMCON0 register. Only CM=110 connects the outputs to pins as shown in figure 7-5

Mark
#4
IO
Starting Member
  • Total Posts : 71
  • Reward points : 0
  • Joined: 2011/01/08 11:45:44
  • Location: 0
  • Status: offline
Re: PIC16F688 Comparator and VREF Connection 2017/08/05 16:57:00 (permalink)
0
mbrowning
They are bits in the CMCON0 register. Only CM=110 connects the outputs to pins as shown in figure 7-5

Yes. I meant, if I wanted to use an external pin, with CM=110, is the buffer an open drain or push-pull? The port diagram only shows one buffer, that is used by the port pin and the comparator.
#5
qhb
Superb Member
  • Total Posts : 5771
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: PIC16F688 Comparator and VREF Connection 2017/08/05 17:01:42 (permalink)
+1 (1)
So that will make it push-pull.
 
#6
IO
Starting Member
  • Total Posts : 71
  • Reward points : 0
  • Joined: 2011/01/08 11:45:44
  • Location: 0
  • Status: offline
Re: PIC16F688 Comparator and VREF Connection 2017/08/12 10:32:19 (permalink)
0
It is not clear from the diagrams.
Is the RC0/AN4/C2IN+ pin now available for general purpose digital I/O?
What about the ADC?
 



Attached Image(s)

#7
IO
Starting Member
  • Total Posts : 71
  • Reward points : 0
  • Joined: 2011/01/08 11:45:44
  • Location: 0
  • Status: offline
Re: PIC16F688 Comparator and VREF Connection 2017/08/12 10:43:50 (permalink)
+1 (1)
I tried to embed the second image in the post, but kept getting "Access denied" garbage.
WTH?!!
#8
CinziaG
rome burns :D
  • Total Posts : 3135
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: PIC16F688 Comparator and VREF Connection 2017/08/12 10:51:47 (permalink)
0
IO
It is not clear from the diagrams.
Is the RC0/AN4/C2IN+ pin now available for general purpose digital I/O?
What about the ADC?
 




Should be; ADC may have another register coming into play
#9
IO
Starting Member
  • Total Posts : 71
  • Reward points : 0
  • Joined: 2011/01/08 11:45:44
  • Location: 0
  • Status: offline
Re: PIC16F688 Comparator and VREF Connection 2017/08/12 10:54:48 (permalink)
0
CinziaG
IO
It is not clear from the diagrams.
Is the RC0/AN4/C2IN+ pin now available for general purpose digital I/O?
What about the ADC?
 




Should be; ADC may have another register coming into play


Should be available for both digital I/O as RC0 and analog input as AN4?


Thanks.
#10
CinziaG
rome burns :D
  • Total Posts : 3135
  • Reward points : 0
  • Joined: 2016/12/07 14:20:36
  • Location: Wien
  • Status: offline
Re: PIC16F688 Comparator and VREF Connection 2017/08/12 12:10:38 (permalink)
0
yes
#11
mbrowning
Caffeine Caffeine
  • Total Posts : 528
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: online
Re: PIC16F688 Comparator and VREF Connection 2017/08/12 17:32:53 (permalink)
+1 (1)
Check for example figure 4-1 in datasheet section 4.2.5 - note 1. If a pin is selected by the comparator mode or by ANSEL to be analog, then digital input is turned off. If TRIS is low for that bit, the digital output is enabled even if analog input is enabled.
 
So if the comparator mode doesn't use a port A pin, and ANSEL doesn't make that pin analog (for ADC), then the pin can be used as digital input.

Mark
#12
Jump to:
© 2017 APG vNext Commercial Version 4.5