What's CNI? I'm guessing something 24F specific? This is how I debounce on 16F and 18F... periodic interrupt reads =20 switch state and shifts into a register. Each time a new value is =20 shifted in, I look for patterns -- for an active-low switch, 11111110 =20 means the switch was just pressed (before any bouncing occurred). =20 00000001 means it was just released (well after all bouncing stops). FWIW, rather than act on a switch press, I start a timer. If the =20 switch is released before a specific time, I perform a "click" action. =20 If the timer reaches a specific value before the switch is released, =20 then I perform a "long-click" action. In a different app, when the =20 switch is released I start a timer and if pressed again within a =20 certain time, it's a double-click. Cheers, -Neil. Quoting Andre Abelian : > Thanks Bob, > > things becoming complicated. it sounds like doable but also becomes =20 > complicated too. > use CNI interrupt as a state machine then change the state as soon =20 > as hit any key=A0 > after let's say 100 scan disable timer base routine. what if while =20 > disabling they press > another key you are going to have missing number. I do not know I =20 > have to think > but it's a good idea > > thanks > > > AA=A0 > > > ________________________________ > From: Bob Blick > To: Microcontroller discussion list - Public. > Sent: Thursday, October 6, 2011 1:24 PM > Subject: Re: [PIC]: keypad debounce issue > > On Thursday, October 06, 2011 10:57 AM, "Andre Abelian"=A0 wrote: > >> I am reading a keypad that is connected to other board. I am using >> PIC24FJ256GB110 >> with CCS PICC compiler. I am using CNI interrupt "port on change" and >> connetced to all 4 rows. >> any time any row goes low it create interrupt but also when it goes high >> creates interrupt too. >> the problem I am having is that I am getting duplicated key "debounce >> issue". Normally=A0 > > Hi Andre, > > Normally I just scan the keyboard every 20 to 50 milliseconds. > > Two reasons why I would use interrupt-on-change: > > 1) I'm saving power in sleep mode and use it to wake up. > 2) I want immediate response to a keypress (fire a weapon?) > > But I would only use the interrupt to trigger a recurring scan. I would > have a recurring timer that would do the actual scans. Only one would be > enabled at a time. After a number of scans with no keypress, I would > enable the interrupt-on-change and disable the timer-based scanning. > > Cheerful regards, > > Bob > > -- > http://www.fastmail.fm - A no graphics, no pop-ups email service > > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .