Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC comparator module

Status
Not open for further replies.

bananasiong

New Member
Hi,
I'm using PIC16F88. If I use only one comparator with output, and I set it as 'two common reference comparators with output', CM2:CM0 = 110 because I need the comparator's output.
If only one comparator is used, then two pins of PORTA are wasted right? Is there any solution for this?

Thanks
 
bananasiong said:
Hi,
I'm using PIC16F88. If I use only one comparator with output, and I set it as 'two common reference comparators with output', CM2:CM0 = 110 because I need the comparator's output.
If only one comparator is used, then two pins of PORTA are wasted right? Is there any solution for this?

Thanks
Hmmm... what about using one independent comparator and setting/clearing RA4 (or any other output pin) when a comparator interrupt occurs?
 
Last edited:
bananasiong said:
Thanks for the suggestion :) But I'm using the timer 1 interrupt for some other purpose.

Who mentioned Timer1? Check the section 'Comparator interrupts' in the datasheet.
 
Then both interrupts will also enter the ISR? And I can check which cause the interrupt.
But what happen if second interrupt happens before the first interrupt returned or vice versa?
 
bananasiong said:
Then both interrupts will also enter the ISR? And I can check which cause the interrupt.
But what happen if second interrupt happens before the first interrupt returned or vice versa?

That's why it's important to ensure that ISR's are short and fast, but the second interrupt will be queued until interrupts are re-enabled.
 
That's why your interrupt routine has to determine where the interrupt came from. Check the xxxIF bits when you enter your interrupt routine.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top