View previous topic :: View next topic |
Author |
Message |
Guard
Joined: 20 Jan 2005 Posts: 43
|
#Int_comp info |
Posted: Thu Jan 27, 2005 9:25 am |
|
|
Hi,
MCU: PIC16f676 PCWH 3.217
Do you know if #int_comp is relative to comparator 1 or 2?
Thank |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Thu Jan 27, 2005 10:13 am |
|
|
Both.
You will have the interrupt if ANY of the two comparators gets triggered. In the ISR you can check the C1OUT and C2OUT registers to know which comparator caused the interrupt.
The generated interrupt is also independent of the direction of the level change on the comparators. You will get an interrupt in BOTH directions when the comparator output changes. It is the 1 or 0 state of the C1OUT (C2OUT) that shows you the actual state of the comparator output.
So there are 4 states when using both comparators that you should serve in an interrupt service routine. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jan 27, 2005 11:13 am |
|
|
Note that some of the PICs actually have a separate interrupt for the other comparator. Look at the datasheet. If the PIC only has one interrupt, then #int_comp is it. If it has 2, then the other one is #int_comp2. |
|
|
Guard
Joined: 20 Jan 2005 Posts: 43
|
|
Posted: Fri Jan 28, 2005 4:34 am |
|
|
Hi,
The PIC16f676 has two flags int for comparators, C1IF and C2IF.
I wrote this code:
//PCWH 3.217
/*
#int_COMP or #int_COMP2
void isr(void)
{
//code
}
but compiler return this errors" Invalid Pre-Processor directive"
may be it has different name?
Thank |
|
|
Ttelmah Guest
|
|
Posted: Fri Jan 28, 2005 5:14 am |
|
|
Guard wrote: | Hi,
The PIC16f676 has two flags int for comparators, C1IF and C2IF.
I wrote this code:
//PCWH 3.217
/*
#int_COMP or #int_COMP2
void isr(void)
{
//code
}
but compiler return this errors" Invalid Pre-Processor directive"
may be it has different name?
Thank |
Re-read the data sheet. The 16F676, only has _one_ comparator interrupt flag.
Are you changing the 'case' setting for the compiler?. The interrupt 'names', are in the include file for the compiler (PIC16F676.h), and the name is always upper case. It is only because case significance is normally turned off, that you can get away with 'versions' line int_COMP.
I'd avoid using the name 'isr'. Too generic. It may already have significance to the compiler. Give the routine a recognisable name (comparator_isr for example).
Best Wishes |
|
|
Guard
Joined: 20 Jan 2005 Posts: 43
|
|
Posted: Fri Jan 28, 2005 6:48 am |
|
|
Hi.
Sorry , but the target isn't PIC16F676 but PIC16C781.
Where is the case setting ( or case sensitive?) option in the project ?I do use mplab always.
INT_COMP in the header file not exists. I changed name from isr() to isr_comparator(), but it hasn't effect
Thank |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Fri Jan 28, 2005 6:54 am |
|
|
You can check with chipedt.exe the actual PICs type config data to see what interrupts are actually allowed to be programmed. (and its syntax also) Be sure not to mess up the config file. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Jan 28, 2005 7:57 am |
|
|
Looks like CCS screwed that one up. |
|
|
Guard
Joined: 20 Jan 2005 Posts: 43
|
|
Posted: Fri Jan 28, 2005 12:31 pm |
|
|
Mark wrote: | Looks like CCS screwed that one up. |
Sorry, but I have not understood
libor wrote: |
You can check with chipedt.exe the actual PICs type config data to see what interrupts are actually allowed to be programmed. (and its syntax also) Be sure not to mess up the config file |
in the chipedit:
COMP 0C.7/8C.7
COMP 0C.6/8C.6
I selected both options , but in the wizard the compiler creates
#INT_COMP
void comparator_isr(void)
{
}
#INT_COMP
void comparator_isr(void)
{
}
Both are relatives only to comparator1 |
|
|
Guard
Joined: 20 Jan 2005 Posts: 43
|
|
Posted: Mon Feb 07, 2005 4:18 am |
|
|
Hi,
PCW 3.218 - Mplab 6.60
Target: PIC16c781
Do you know which is the option in device edit, for #int_comp2 ( comparator 2)??
Thank |
|
|
|