CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

#Int_comp info

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guard



Joined: 20 Jan 2005
Posts: 43

View user's profile Send private message

#Int_comp info
PostPosted: Thu Jan 27, 2005 9:25 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jan 27, 2005 10:13 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Thu Jan 27, 2005 11:13 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jan 28, 2005 4:34 am     Reply with quote

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







PostPosted: Fri Jan 28, 2005 5:14 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jan 28, 2005 6:48 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jan 28, 2005 6:54 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Fri Jan 28, 2005 7:57 am     Reply with quote

Looks like CCS screwed that one up.
Guard



Joined: 20 Jan 2005
Posts: 43

View user's profile Send private message

PostPosted: Fri Jan 28, 2005 12:31 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Feb 07, 2005 4:18 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group