This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Starterware/CC2541: CC2541 - analog comparator interrupt issue

Part Number: CC2541


Tool/software: Starterware

Hi,

I am setting up analog comparator on CC2541 and everything works but there is an issue: Even when there is no Flag related to the specified interrupt the interrupt service routine is being called?

In software initialization I do this:

  EA = 1; // Each interrupt source is individually enabled or disabled by setting its corresponding enable bit.
  P0IFG = 0; //Clear interrup flags for PORT0
  PICTL = 0x01; //Interrup on fallaing edge of P0
  CMPCTL |= CMPCTL_EN; //Enable the comparator for P0_5 & P0_4
  P0IEN = 0x20; //Enable PORT0_5 interrupt
  P0IE = 1; //Enable PORT0 interrupt    
  P0IFG = 0; //Clear interrup flags for PORT0

The following is interrupt service routine:


#pragma vector = P0INT_VECTOR
__interrupt void PORT0_ISR(void)
{

  P0IE = 0; //Disable PORT0 interrupt  
  P0IEN = 0x00; //Disable PORT0_5 interrupt    
    
  if(P0IFG & 0x20)
    pulse_input_counter++;
 
  // Clear PORT0_5 Interrupt Flag
  P0IFG = 0;
  CMPCTL = 0x02;
 
  P0IE = 1; //Enable PORT0 interrupt
  P0IEN = 0x20; //Enable PORT0_5 interrupt   
}

Thank you