Keyboard interrupt

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

Keyboard interrupt

2,040 Views
ernestsnaith
Contributor I
I have been tring to get the keyboard interrupt to work on MC9S08QG8. I have simplifed the code to the following to try and find the problem.
 
Code:
void main(void) {   SOPT1_COPE = 0;  //diable COP   // KBI Set Up foe SW1   KBIPE_KBIPE1 =1;   /* Enable Keyboard Pin */                                     KBISC_KBIE = 1;    /* Enable Keyboard Interrupts */   KBISC_KBACK = 1;   /* Clear Pending Keyboard Interrupts */   PTAPE_PTAPE1 = 1;   /* Enable Pullup for Keyboard pin */   KBISC_KBIMOD = 1;   PTBDD_PTBDD1 = 1;  //A1   EnableInterrupts;    for(;;)                   // Loop Forever  {  }}//*******************************************// KBI ISR         // interuptinterrupt 18 void   KBI_ISR(void) {     PTBD_PTBD1 = ~PTAD_PTAD1;    /* toggle Port */  KBISC_KBACK = 1;
}

 

The waveform from a light gate is input to the keyboard interupt pin and i expect the output pin to toggle on change. However, altough it does most of the time many interupts are missed. Below are the input and output waveforms. I have zoomed in on input waveform and it appears to be clean. Any suggestions greatly appreciated.

Many Thanks

 


 
Labels (1)
0 Kudos
Reply
1 Reply

636 Views
peg
Senior Contributor IV
Hi Ernest,
 
You can see two problems from the supplied waveform.
1. Sometimes it fails to respond.
2. Sometimes it apparently responds to both edges/levels.
 
This is because you have select level sensitivity instead of edge (leave KBIMOD at 0)
 
If you want it to toggle at each edge you would have to flip the polarity in the ISR, but watch the pullup/downs.
 
You should also look at it with a faster timebase and the problem may be more apparent.
 
0 Kudos
Reply