AnsweredAssumed Answered

comparator interrupt handler (doesn't get called? or does it?)

Question asked by rick stuart on Apr 30, 2015
Latest reply on May 11, 2015 by rick stuart

Hi,

 

I have a KL27 on one of Freescale's development boards here and have not been able to get it to call a comparator interrupt routine.  I'll start out just describing what's going on.  If someone see the "bug" I've over looked that would be great.  If not, I can start posting bits of code.

 

I have a bit of Freescale example code where the D/A block of the KL27 is set up to supply a programmable reference to the Comparator block of the KL27.  My signal is the other input to the Comparator.  I wrote code to sample and send out the Comparator result to an external pin.  I can see the input and output perform as expected when I run this code.

 

Now I have added a method to handle the Comparator's interrupts.  I have set up the KL27's interrupt vectors for the CMP0 interrupt.  And I have set up the falling edge interrupt of the Comparator.  But now when I run my code it does nothing.  When I stop it, the program counter is at a place in memory that is outside of anything in the memory map the linker put together for this program.  The bit of code, in infinite loop, looks suspiciously close to the default interrupt handler that "should" be used if no interrupt handler was written for the "bitweak" defined interrupt.

 

Now, did the program go "south" because of a CMP0 interrupt??  Well, if I comment out the line that sets up the KL27's interrupt vector for the CMP0 the program works as expected.  Recall the program is written as an infinite loop which samples the state of the CMP0 comparator and outputs that to a pin.   That all works w/o the KL27's interrupt vector for CMP0 enabled.

 

Likewise, I can comment out the line that sets up the falling edge interrupt of the Comparator and get the program to sample and report the state of CMP0.

 

As one last test, I restored all the code and stopped sending my external signal into the KL27's Comparator.  That too allowed the program to work.  I could stop in the code, single step and then continue execution.

 

At this point, it sound like my interrupt code is bad and sending the program into a spin.  So I set a break point so the execution should stop as soon as it jumps to the interrupt handler.  That never breaks.  I then, just in case, move the break point to the default handler.  That never breaks.

 

Now what?

 

-thanks for any help or suggestions

Outcomes