Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Need help with assembly program for lcd and keyboard

Status
Not open for further replies.

E.C

Newbie
Joined
Dec 14, 2022
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
32
hey im new here and need help with Uni project
im using a 2x16 display and 4x3 keyboard plugged into a Arduino Leonardo.

ive written most of the code and made it work but im pretty new with the Assembly
so what im trying to do is feed the data from the keyboard to the lcd so it displays it .
but i cant figure out how to make it so the data the program reads from the keyboard gets sent to the display.

btw the delay.inc and lcd.inc is sperate and thats where i have the delay and lcd programs.

;==============================================================================
; Definitions of registers, etc. ("constants")
;==============================================================================
.EQU RESET = 0x0000
.EQU PM_START = 0x0056
.DEF TEMP = R16 ; Define Temp = R16
.DEF RVAL = R24 ; Define R24 tille namnet RVAL
.EQU NO_KEY = 0x0f


;==============================================================================
; Start of program
;==============================================================================
.CSEG
.ORG RESET
RJMP init

.ORG PM_START
.INCLUDE "delay.inc"
.INCLUDE "lcd.inc"
;==============================================================================
; Basic initializations of stack pointer, I/O pins, etc.
;==============================================================================
init:
; Set stack pointer to point at the end of RAM.
LDI TEMP, LOW(RAMEND)
OUT SPL, TEMP
LDI TEMP, HIGH(RAMEND)
OUT SPH, TEMP
; Initialize pins
CALL init_pins
; Jump to main part of program
CALL lcd_init
RJMP main

;==============================================================================
; Initialize I/O pins
;==============================================================================
init_pins:
LDI TEMP, 0xFF ; Pin PB4-PB7= 0000
OUT DDRB, TEMP ; DDRB = R16 output
OUT PORTB, TEMP ; Pull up för port B
LDI TEMP, 0xFF ; PF4_PF7 = 0000
OUT DDRF, TEMP ; DDRF = R16
LDI TEMP, 0xFF ;Pin PD6-PD7 = 0000
OUT DDRD, TEMP ; DDRB = R16 becomes output
LDI TEMP, 0xF0 ;
OUT DDRE, TEMP ; PE6 becomes input

RET

;==============================================================================
; Main part of program
;==============================================================================
main:
IN TEMP, PINB ; reads data from PINB to TEMP
SWAP TEMP
MOV RVAL,TEMP ; copies TEMP to R24

CALL read_keyboard ; read_keyboard subrutine
LSL RVAL ; Skift to left
LSL RVAL
LSL RVAL
LSL RVAL
LDI RVAL, 0xFF //does nothing
OUT PORTF,RVAL ; PORT F to R24
NOP
NOP
RJMP main ; 2 cycles

LCD_WRITE_CHAR 'K'
LCD_WRITE_CHAR 'E'
LCD_WRITE_CHAR 'Y'
LCD_WRITE_CHAR ':'

LDI R24, 0xC0
RCAll lcd_write_instr



loop:
RJMP loop

;==============================================================================
;SUBRUTINE READ_KEYBOARD
;==============================================================================
read_keyboard:
LDI R18, 0 ; reset counter
scan_key:
MOV R19, R18
LSL R19
LSL R19
LSL R19
LSL R19
OUT PORTB, R19 ; set column and row
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
SBIC PINE, 6
RJMP return_key_val
INC R18
CPI R18, 12
BRNE scan_key
LDI R18, NO_KEY ; no key was pressed!
return_key_val:
MOV RVAL, R18
RET
 

Would be helpful if you post a schematic and part number of display.


Regards, Dana.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top