Analog comparator interrupt handler

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Analog comparator interrupt handler

350 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CroesJeroen on Fri Feb 01 15:34:33 MST 2013
Hello guys,

I'm facing a difficulty with the analog comparator. I use 1.66V for the - input of the comparator (with the voltage ladder) and a analog input for the + input of the comp.

The output of the comparator0 works just fine, it go's high when V+>V-. I'm debugging it and checking the comparator register, CMP0STAT  give the status of the comparator.

I added the comparator interrupt to the NVIC but it just doesnt jump to the handler?!

LPC1227

void InitCMP(void){
set the inputs, comparator, voltage ladder....
 
NVIC_ClearPendingIRQ(CMP_IRQn);
NVIC_EnableIRQ(CMP_IRQn);

}



void COMP_IRQHandler(void){

LPC_ACOMP->CMP |= INTCOMPCLR; // reset the interrupt status
}


Hopefully someone used this before and maybe encountered the same problem!

kind regards
0 Kudos
2 Replies

269 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CroesJeroen on Sun Feb 03 10:35:43 MST 2013
Hello guys,

I've got it, I placed a breakpoint on the while so when I pressed run it always stopped on the while. The output of the comparator gos high but theres a certain delay and that why it never went to the interrupt handler. After removing the breakpoint on the while and letting it run, it went to the handler.
0 Kudos

269 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Fri Feb 01 16:14:25 MST 2013
[FONT=Tahoma][SIZE=2]I don't use CMSIS/RedLib, but suggest that you double check that the addresses
of your handler (COMP_IrqHandler -- by the way, I [I]really[/I] hate underscores!)
is at the proper place in the vector table.

IIRC and depending on the compier used, that [I]should[/I] be done -- for instance, I think
the Code Red setup defines a handler for all possible interrupts with the 'weak' attribute
(in starup_something.c) whereupon you defininition will 'override' the weak attribute
and be used for interrupt handling. I haven't time to check, but the name of the handler
must be [I]exactly[/I] the same -- and I don't think that your's is.
Also, remember to declare your handler as a public symbol.

Hope that helps a bit.
Mike

[/SIZE][/FONT]
0 Kudos