
void keypad_isr(void) interrupt 7 using 1
{
    unsigned char mask = 0x01;
    unsigned char index;
    bit test;

	CurrentState = P0 & 0x4E;
	
	
   if (WorkingState != CurrentState){                 //Compare the inputs with what we had last time around
       //if something has changed we need to determine which its have changed
       WorkingState ^= CurrentState;
       for (index = 0; index <= 7 ; index++){
	       test = WorkingState & mask;         			//copy the bit to the test bit
          if (test== 1)digital_input_count[index]++;  //if the bit has changed then update then reset the debounce counter
          mask <<= 0x01;                              //shift the mask to the left 1 bit
       }//end for
   }//endif 
      

	WorkingState = CurrentState;
                                                      //update the workingstate with the current value
  KBPATN = P0 & 0x4E;											//change the pattern to reflect the new state
  																		//so we only get an interrupt when something changes
  																		
  // clear interrupt flag

  
  KBCON &= 0xFE;
  

}
