View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
Help With Newguy's Keypad Driver |
Posted: Wed Oct 05, 2005 6:18 pm |
|
|
I'm using the driver outlined in Newguy's post:
http://www.ccsinfo.com/forum/viewtopic.php?t=19726
The problem I'm having is that I get a keypress interrupt with both a press and a release. That generates a problem with a number entry routine that I've written. It simply taking the digit entered and multiplying the previous by 10 and adding the new entry. It works great as long as I press and hold the key, but as expected when I release, the previous value is ten times the correct value. (i.e. my character handling routine gets triggered twice for every keypress.)
I have tried modifying the ISR to only detect changes from the "resting state" of portb: 0b11110000, but that causes problems upon the release.
I have considered modifying my character handler to only accept every other entry.... but I have more pride than that.
Is there any easy way to toss out the release interrupts?
Thanks again for all the help,
John |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Wed Oct 05, 2005 10:42 pm |
|
|
I think I've got a solution but I think I may have a hardware problem.
When I press and hold the switch on B0/B4 the LCD constantly refreshes. I have confirmed with LED flashes that the ISR and the "if keypressed" routines are not firing with the pushbutton held down.
BTW LCD is on port D.
Any help or suggestions would be greatly appreciated.
John |
|
|
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
|
Posted: Thu Oct 06, 2005 8:55 am |
|
|
I found the source of the problem(s) and a solution to the "interrupt on key release" problem.
To only register the keypress and not the release modify the ISR as follows:
Code: |
#int_RB
void RB_isr(void) {
if (old_b_state != portb) {
if(old_b_state == 0b11110000) { //only register keypress on press
key_pressed = TRUE;
}
old_b_state = portb;
}
}
|
The source of my other problems are from a state machine that I'm trying to understand. |
|
|
William H. Conley III
Joined: 27 May 2004 Posts: 17 Location: Tucson, AZ
|
|
Posted: Thu Oct 27, 2005 9:08 pm |
|
|
It must suck having to talk to your self....
- Red Helmet Out _________________ - Bill |
|
|
Bart
Joined: 12 Jul 2005 Posts: 49
|
|
Posted: Fri Oct 28, 2005 5:07 am |
|
|
Thats a nice remark !! _________________ I like Skype (www.skype.com), my username is BplotM |
|
|
|