Hi,
Just needed some help with my code,
Im using ATMEGA8515 and a FM629 Board.
I need to enter a number on the keypad and output on the LED,
I got the LEDs and that down packed, i just need help, as my code seem to be only reading in the first Row, even if I enter any number from the second/third ROW
; ; Lab5-a assembler program ; .include "m8515def.inc" .def temp = r16 .def num = r17 ; set 7-segment display labels .equ ZERO = 0b00111111 .equ ONE = 0b00000110 .equ TWO = 0b01011011 .equ THREE = 0b01001111 .equ FOUR = 0b01100110 .equ FIVE = 0b01101101 .equ SIX = 0b01111101 .equ SEVEN = 0b00000111 .equ EIGHT = 0b01111111 .equ NINE = 0b01101111 .equ STAR = 0b01110110 .equ HASH = 0b01001001 RESET: ; *** set up Direction Registers *** ldi temp, 0b01110000 out DDRB, temp ldi temp, 0b00001111 out PORTB, temp LOOP: in temp,PINB ldi temp,0b00001111 ; PB4..PB6=Null, pull-Up-resistors to input lines out PORTB,temp ; of port pins PB0..PB3 nop ; one nop delay inherent in AVR circuitry nop ; second nop delay to ensure correct values in temp,PINB ; read key results ori temp,0b11110000 ; mask all upper bits with a one cpi temp,0b11111111 ; all bits = One? brne KEY ; yes, no key is pressed rjmp LOOP KEY: ; checking Column 1, Row 1-4 through PORTB ldi temp, 0b10111111 ; set a mask with only column1 to 0 out PORTB, temp ; output to PortB nop ; one nop delay inherent in AVR circuitry nop ; second nop delay to ensure correct values in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00000111 ; compare with ....0111 (Row1=0) brne ROWA2 ; branch if not equal, to Next ROW ldi temp, ONE out PORTA, temp rjmp LOOP ROWA2: in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00001011 ; compare with ....0111 (Row1=0) brne ROWA3 ldi temp, FOUR out PORTA, temp rjmp LOOP ROWA3: in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00001101 ; compare with ....0111 (Row1=0) brne ROWA4 ldi temp, SEVEN out PORTA, temp rjmp LOOP ROWA4: in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00001110 ; compare with ....0111 (Row1=0) brne COL2 ldi temp, STAR out PORTA, temp rjmp LOOP COL2: ldi temp, 0b11011111 ; set a mask with only column2 to 0 out PORTB, temp ; output to PortB nop ; one nop delay inherent in AVR circuitry nop ; second nop delay to ensure correct values in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00000111 ; compare with ....0111 (Row1=0) brne ROWB2 ; branch if not equal, to Next ROW ldi temp, TWO out PORTA, temp rjmp LOOP ROWB2: in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00001011 ; compare with ....0111 (Row1=0) brne ROWB3 ldi temp, FIVE out PORTA, temp rjmp LOOP ROWB3: in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00001101 ; compare with ....0111 (Row1=0) brne ROWB4 ldi temp, EIGHT out PORTA, temp rjmp LOOP ROWB4: in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00001110 ; compare with ....0111 (Row1=0) brne COL3 ldi temp, ZERO out PORTA, temp rjmp LOOP COL3: ldi temp, 0b11101111 ; set a mask with only column1 to 0 out PORTB, temp ; output to PortB nop ; one nop delay inherent in AVR circuitry nop ; second nop delay to ensure correct values in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00000111 ; compare with ....0111 (Row1=0) brne ROWC2 ; branch if not equal, to Next ROW ldi temp, THREE out PORTA, temp rjmp LOOP ROWC2: in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00001011 ; compare with ....0111 (Row1=0) brne ROWC3 ldi temp, SIX out PORTA, temp rjmp LOOP ROWC3: in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00001101 ; compare with ....0111 (Row1=0) brne ROWC4 ldi temp, NINE out PORTA, temp rjmp LOOP ROWC4: in temp, PINB ; now we can check "˜temp' for which row = 0 andi temp, 0b00001111 ; just righthand nibble cpi temp, 0b00001110 ; compare with ....0111 (Row1=0) brne NoKey ldi temp, HASH out PORTA, temp NoKey: ; *** Output value to LEDs *** rjmp LOOP
How do i modify this so the values are read in correct?
ps.
The column bits are used as outputs and Row bits as inputs.