CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Help With Newguy's Keypad Driver

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

Help With Newguy's Keypad Driver
PostPosted: Wed Oct 05, 2005 6:18 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Oct 05, 2005 10:42 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 06, 2005 8:55 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Oct 27, 2005 9:08 pm     Reply with quote

It must suck having to talk to your self....

- Red Helmet Out
_________________
- Bill
Bart



Joined: 12 Jul 2005
Posts: 49

View user's profile Send private message

PostPosted: Fri Oct 28, 2005 5:07 am     Reply with quote

Laughing Laughing Laughing Thats a nice remark !!
_________________
I like Skype (www.skype.com), my username is BplotM
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group