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
|
|