WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
What is FASM G
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Keypad

apocNAO
Quote Post


New Member
*

Group: Members
Posts: 1
Member No.: 37835
Joined: 15-September 10


A micro-controller with pins PB0-PB6 is connected to the 7 pins of a keypad where 4 rows (output) connect to PB3-PB6 and 3 columns (input) to PB0-PB2. The input column bits will only be set to high after a key is pressed from a row that is set high at the time (keys are like circuit switches). To find which key has been pressed, rows are sequentially set high so if a key is pressed on a high row a column bit will be set high. I have LEDs connected to the rows, until a key is pressed all lights appear lit because they are being iterated through so fast. My objective is to terminate the program after a key is pressed leaving the light matching the row bit high. Problem is this code is not leaving the expected light on so it must be terminating with the wrong row bit set high.

What i am attempting to do with the code is shift through each bit of PB3-6, at each row bit shift, all column bits are shifted and the carry bit is checked to see if a key is pressed and terminated if so. I would like to know if this code is not doing what i'm describing here.
CODE

                 LDAA  #%01111000
                 STAA  DDRB
           
mainLoop:        LDAA  #%01000000
                 STAA  PORTB
                 LDAA  PORTB
                 LDAB  PORTB        
                 LDX    #3
                 LDY    #4    

STROBE:          LSRA        
                 BCS   FOUND  
                 DEX              
                 CPX   #0
                 BNE   STROBE
                 LDX   #3
                 LSRB
                 STAB  PORTB
                 LDAA  PORTB
                 DEY
                 CPY   #0
                 BEQ   mainLoop
                 BRA   STROBE
           
FOUND:           LDAB  PORTB
                 JSR   OUT2HEX

Sponsored Links
PMEmail Poster
Top
shoorick
Quote Post


Extremely Active Member
******

Group: Admins
Posts: 2342
Member No.: 160
Joined: 22-June 04


not clear: attach an image with schematic please, at least pins, leds and keys. and what MCU are you using exactly? in any case it is better to scan with shifting zero then shifting high level (high level on output is inactive while on zero level the current goes into the ground through MCU pin)
PMEmail PosterUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google