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
 
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.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…