PDA

View Full Version : Comparators - like descrite components?



kevj
- 9th October 2007, 01:56
If I activate one of the comparators on a PIC, does it behave completely independant of program execution and timing? Assuming I've configured for the inverting input and non-inverting input, as well as a certain pin as the output... can I just run my program then and have those 3 pins act as a "descrite comparator" all by themselves?

I've updated a circuit and it turns out I'll need one single comparator, but it has nothing to do with my program, I could essentially add a single descrite comparator to the board and be done, but I've got 4 unused I/O's on my PIC and realized I can probably use those pins for this task without adding another component. The use of the comparator in this case is for a completely separate part of the circuit, though it's fed by the same power supply and ground so it should be electrically compatible.

Thanks!

Melanie
- 9th October 2007, 07:08
> If I activate one of the comparators on a PIC, does it behave completely independant of program execution and timing?

Yes.

> Assuming I've configured for the inverting input and non-inverting input, as well as a certain pin as the output... can I just run my program then and have those 3 pins act as a "descrite comparator" all by themselves?

The Output pin will be independant (as will the input pins). The Output from the Comparator only trips a flag in a Register. It's up to your program to look at that flag if you need to... if you don't, then it's going to be a completely independant piece of hardware. Your program WILL have to initialise the pins for Analog use, select the Comparator type (usually there are several options) and set the pins for their approprate I/O.

> but I've got 4 unused I/O's on my PIC and realized I can probably use those pins for this task without adding another component.

You normally can't assign your own pins, they are fixed in hardware - check the Datasheet.

kevj
- 9th October 2007, 18:17
Thanks Melanie! Very helpful. That answer makes me very happy. :)