fastbike
Junior Member level 1
- Joined
- Feb 16, 2005
- Messages
- 17
- Helped
- 1
- Reputation
- 2
- Reaction score
- 0
- Trophy points
- 1,281
- Location
- South of the Equator
- Activity points
- 1,460
Hi,
I'm reading a 4 x 7 matrix membrane keypad . I'm using a PIC16F88 and use the PortB4:7 pins for the colums and the PortA0:7 pins for the rows.
I've set my code to setup the column pins as inputs, held high by the internal pullups. The rows are set as outputs and set to low.
In my main code loop I scan PortB4:7 looking for a low column pin - the idea is that when a key is pressed the PortB pin will go low.
If this happens I then set that column as an output (low), set the rows as input (held high with external pullups) and look for the row that is low.
This works well.
My problem is this:
I want to use the SLEEP command so I can turn the PIC off to save battery power. I want to wake it up using the interrupt on PortB function.
However, when I enable the RBIE bit, my code stops working or works intermittently.
I'm clearing the RBIF flag in the interrupt procedure. I've tried setting a 50mSec delay to debounce the key before I clear the flag but find this makes little difference.
Have I overlooked something simple ?
I'm reading a 4 x 7 matrix membrane keypad . I'm using a PIC16F88 and use the PortB4:7 pins for the colums and the PortA0:7 pins for the rows.
I've set my code to setup the column pins as inputs, held high by the internal pullups. The rows are set as outputs and set to low.
In my main code loop I scan PortB4:7 looking for a low column pin - the idea is that when a key is pressed the PortB pin will go low.
If this happens I then set that column as an output (low), set the rows as input (held high with external pullups) and look for the row that is low.
This works well.
My problem is this:
I want to use the SLEEP command so I can turn the PIC off to save battery power. I want to wake it up using the interrupt on PortB function.
However, when I enable the RBIE bit, my code stops working or works intermittently.
I'm clearing the RBIF flag in the interrupt procedure. I've tried setting a 50mSec delay to debounce the key before I clear the flag but find this makes little difference.
Have I overlooked something simple ?