Keyboard interrupt

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Keyboard interrupt

2,042 次查看
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

 


 
标签 (1)
0 项奖励
回复
1 回复

638 次查看
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 项奖励
回复