??? 08/14/06 10:59 Read: times |
#122189 - LPC 9xx Can't clear KBIF |
Hi all
I am using an LPC925 with the KBI functions and whilst I have read the threads on here and looked around suitably, I cannot for the life of me figure out what is going on. basically I can trigger a Keypad Interrupt no problem, and I can poll my IO to see which port triggered the interrupt. The issue I have is that I can NEVER clear the Keypad interrupt flag. so after the interrupt has fired once, it will continue to keep firing even when the IO has reverted to the inactive state. I have tried: 1, changing the pattern 2, changing the mask (this will stop it but how can I determine when the next KBI is fired?) 3, disable the EKBI = 0; then clear KBCON &=0xFE then set EKBI = 1; plus a whole series of other useless attempts. Basically what I want to do is increment a counter on when any of 4 inputs is active. here is the relevant code void keypad_init (void) { // define pattern KBPATN = 0x4E; // define P0 pins that trigger interrupt KBMASK = 0x4E; // pattern must not match KBCON = 0x00; // set P0 pins as inputs //P0M1 |= 0x4E; //P0M2 &= ~0x4E; // set isr priority to 0 IP1 &= 0xFD; IP1H &= 0xFD; // enable keypad interrupt EKBI = 1; } This is in the interrupt routine 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; } Please no comments on coding style, commenting style, layout, or other stuff at the moment, it is horrible, I know, I am still fiddling around trying to get it going. This is the same in the Emulator (Acqura) and the Simulator (Raisonance). Any ideas. Thanks Marshall |
Topic | Author | Date |
LPC 9xx Can't clear KBIF | 01/01/70 00:00 | |
Turn it off? | 01/01/70 00:00 | |
I could turn it off | 01/01/70 00:00 | |
to turn the KBIF, you have to change the condition | 01/01/70 00:00 | |
Thanks Erik - I'll give it a go | 01/01/70 00:00 | |
an added comment | 01/01/70 00:00 | |
What is the rate of change on the input signals? | 01/01/70 00:00 | |
nothing of value except the ability to wake up the | 01/01/70 00:00 | |
Interrupt for pulse train | 01/01/70 00:00 | |
that's basically what the KBI does | 01/01/70 00:00 | |
Rate of change ~<100kHz | 01/01/70 00:00 | |
why not? | 01/01/70 00:00 | |
I did not discuss | 01/01/70 00:00 | |
It is ok but KBIF is set forever | 01/01/70 00:00 | |
that you do not clear the reason | 01/01/70 00:00 | |
I change the state of the pin before | 01/01/70 00:00 | |
could be the problem | 01/01/70 00:00 | |
Simulators problem![]() | 01/01/70 00:00 | |
Remote Control using AT89C2051 schematic | 01/01/70 00:00 | |
just great | 01/01/70 00:00 | |
Another BS answer. | 01/01/70 00:00 | |
No BS, I did | 01/01/70 00:00 |