Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Confused with interrupts for internal comparator of dspic33ev.

Status
Not open for further replies.

electronicsman

Full Member level 5
Joined
May 4, 2012
Messages
291
Helped
11
Reputation
22
Reaction score
12
Trophy points
1,298
Activity points
3,737
I am very confused with configuring the interrupt for internal comparator of dspic33ev. As per the data sheet these are the statements




I am very confused with the statements. So my code will look like this. Please suggest if this code is Ok.
Code:
void __attribute__((__interrupt__,__no_auto_psv__)) _CMP1Interrupt(void)
{
static char testdata;

testdata = CM1CONbits.COUT /* Note 1: The comparison required for generating interrupts is based on the current comparator state and the last read    
                                             value of the comparator outputs. Reading the COUT bit in the CMxCON register will update the values used for the  
                                               interrupt generation */
/* Both the CMPIF and CEVT bits must be reset by clearing them in software. */
CM1CONbits.CEVT = 0;
IFS1bits.CMPIF = 0
}
 

You have to initialize your comparator to work according to your application. This step is missing.
For example CMxCON register should be first configured. Especially EVPOL if you want to use interrupts. Other than that your ISR looks ok.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top