Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 22, 2024, 02:42:33 02:42


Login with username, password and session length


Pages: [1]
Print
Author Topic: keypad and interrupt  (Read 4312 times)
0 Members and 1 Guest are viewing this topic.
babatundeawe
Junior Member
**
Offline Offline

Posts: 43

Thank You
-Given: 60
-Receive: 13


« on: January 21, 2011, 04:57:11 04:57 »

i intend to make this project a digital code lock. i want the micro to do other things but on tapping the keypad an iterrupt should occur and goto keypad isr for keyencoding after the encoding the program shud return to what it was doing. thanks
Logged
hate
Hero Member
*****
Offline Offline

Posts: 555

Thank You
-Given: 156
-Receive: 355


« Reply #1 on: January 22, 2011, 11:15:46 11:15 »

Possible with that configuration. U have to use a timer to scan the pins (i.e. columns, B0-B3) and when a change occurs in the current state of the pins the interrupt for pin change (the one on the B4-B7 pins) will trigger. Then comes the bouncing problem. U may use the same timer to disable the scanning for a certain debouncing period. I've applied this technique once in a project, it's quite complicated though.

Regards...
Logged

Regards...
TomJackson69
Active Member
***
Offline Offline

Posts: 218

Thank You
-Given: 26
-Receive: 63


« Reply #2 on: January 23, 2011, 04:27:33 04:27 »

Remember port B has Interrupt On Change feature on RB7-RB4. --- as "hate" indicated above ---

If you use this feature, it will make detection of key press easier.
Set up the pin you want to use as Int-On-Change as INPUTand ENABLE it.

Use RBIE: RB Port Change Interrupt Enable bit

And RBIF: RB Port Change Interrupt Flag bit

Write an interrupt routine to compare OLD RB and NEW RB (upper 4 bits only, use AND to clear the lower nib)

If any of the pin change you will know and take action accordingly. A DEBOUNCE code also need.

You need to look at the SPEC to write your routine.

Good luck

Tom
« Last Edit: January 23, 2011, 04:45:00 04:45 by TomJackson69 » Logged

Con Rong Chau Tien
falcon _bd
Active Member
***
Offline Offline

Posts: 139

Thank You
-Given: 66
-Receive: 117


falconbd.com


WWW
« Reply #3 on: January 23, 2011, 08:53:18 08:53 »

check it out

http://www.sonsivri.com/forum/index.php?topic=34335.msg108490#msg108490
Logged

babatundeawe
Junior Member
**
Offline Offline

Posts: 43

Thank You
-Given: 60
-Receive: 13


« Reply #4 on: January 26, 2011, 07:59:03 19:59 »

i will give all the sugestion a try and feed you guys back
Logged
babatundeawe
Junior Member
**
Offline Offline

Posts: 43

Thank You
-Given: 60
-Receive: 13


« Reply #5 on: January 27, 2011, 11:14:08 23:14 »

guys, i tried to make adjustment to the code as directed. but i noticed that gie is not cleared/disabled when the isr is called can u please tell where i am getting it wrong.
Logged
rtm
Junior Member
**
Offline Offline

Posts: 56

Thank You
-Given: 104
-Receive: 93


a.k.a. klug


« Reply #6 on: January 28, 2011, 07:25:18 07:25 »

GIE is auto-cleared when interrupt is calling by hardware (if you jumping to interrupt routine by program it will be not cleared). To set it back when you go out from interrupt you need to use RETFIE instructon.

Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC