Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 3rd May 2006, 02:18 PM   #1
Default Keypad Code

I've been looking through the keypad code from Nigel's tut site (http://www.winpicprog.co.uk/pic_tutorial9.htm) and would like to include it in my program.

My asm is a bit rusty but from going through the code 'KEYS' procedure goes into a loop intul a key is pressed.

In the program I am writing I need to constantly check one of the RA ports for a input so the program cannot loop at the keys subroutine otherwise it will never get to the input checking routine. What I need is something like:

Main
call check_keys
; above routine should return the key pressed in W, otherwise W=0
; if W<>0 Then do something here

call check_ra2

loop Main

How do I go about getting the keypad routine to not loop until a key is pressed?
gregmcc is offline  
Old 3rd May 2006, 02:35 PM   #2
Default

Quote:
Originally Posted by gregmcc
I've been looking through the keypad code from Nigel's tut site (http://www.winpicprog.co.uk/pic_tutorial9.htm) and would like to include it in my program.

My asm is a bit rusty but from going through the code 'KEYS' procedure goes into a loop intul a key is pressed.

In the program I am writing I need to constantly check one of the RA ports for a input so the program cannot loop at the keys subroutine otherwise it will never get to the input checking routine. What I need is something like:

Main
call check_keys
; above routine should return the key pressed in W, otherwise W=0
; if W<>0 Then do something here

call check_ra2

loop Main

How do I go about getting the keypad routine to not loop until a key is pressed?
Simply alter the routine so it only loops a number of times then gives up, return an unused value (like 255) in W so you can check if a button was pressed or not (or set a flag).
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 3rd May 2006, 08:52 PM   #3
Default

Thanks - now why didn't I think of that
gregmcc is offline  
Old 11th May 2006, 05:28 AM   #4
Default

See key debouncing problems. If you want to avoid it use 74922

Code for interfacing Keypad with parallel port of a computer is available in book
MY EXPERIENCE IN PARALLEL PORT INTERFACING
It is a free book. You can get it from yahoo group-booksbybibin

http://groups.yahoo.com/group/booksbybibin/

Bibin John
www.bibinjohn.tk
bibinjohn is offline  
Old 11th May 2006, 06:28 AM   #5
Default

or a 40-50ms delay and re-checking the keystate will be sufficent for debounce
__________________
Gods own Country
Incredible !ndia

www.flickr.com/photos/_akg/

"Give a man a fish, and he will eat for a day. Teach that man to fish, and he will eat for a lifetime."
akg is offline  
Old 11th May 2006, 09:01 AM   #6
Default

Quote:
Originally Posted by akg
or a 40-50ms delay and re-checking the keystate will be sufficent for debounce
Yes, software de-bouncing makes a LOT more sense than adding a 74992.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Reply

Tags
code, keypad

Thread Tools
Display Modes




All times are GMT. The time now is 03:05 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker