Program for dispaying lcd characters, Assembly Language

Assignment Help:

#include"lcd.asm"       ; assembly file is included for displaying lcd characters

Main:

PORTA EQU 0xF80  ; PORTS

PORTB EQU 0xF81

PORTC EQU 0xF82

PORTD EQU 0xF83

REG      EQU 0X7F

COUNT EQU 255

EEDATA EQU 0XFA8

TRISA EQU 0xF92    ; DATA CONTROL REGISTER

TRISB EQU 0xF93

TRISD EQU 0xF95

TRISC EQU 0xF94

count1              RES 1           ;variable used in delay routines

counta              RES 1           ;variable used in delay routines

countb              RES 1           ;variable used in delay routines

 #define lcd_data    LATC        ;8 bit data to the lcd will be on PORTC

 #define lcd_rs      LATA,0      ;register Select (see note at top of program)

 #define lcd_rw      LATA,1      ;read/write, write = 0

 #define lcd_en      LATA,2      ;enable data transfer

 #define lcd_busy    PORTC,7     ;lcd busy flag is read on lcd DB7

ORG 0h          ;

 

CALL init_lcd            ;call the initialization routine

CALL Delay30           ;wait here after initialization routine done.

CLRF TRISD ; port d outport

MOVLW 0Fh ; PIN 0-3 AS INPUT AND 4-7 AS OUTPUT

MOVWF TRISC        ;VALUE TO TRISC

L1:

            MOVLW 0x06 ; SHIFT CURSOR POSITION BY 1

            CALL lcd_write         ;write to lcd

            CALL  get_char          ;code to converthex to ascii

            SUBLW 0xA7 ;CHECKING FOR CLEAR CHARACTER

                        BZ L2 ;BRANCH TO LOOP L2 TO CLEAR TH LCD

            MOVLW REG

            SUBLW 0x17 ; compare for addition key '+'

                        BZ L3

            CALL lcd_write

            CALL DELAY

            GOTO L1

L2:      

            movlw   b'00000001'   ;CLEAR DISPLAY(0x01)

    call    lcd_write       ;WRITE COMMAND TO LCD

    call    busy               ; CHECK BUSY FLAG

            GOTO L1

L3:

            CALL ADDITION

ADDITION

            ADDWF REG,0,1 ;SUM WILL BE STORED IN W REGISTERS

            DAW

RETLW

**********************get_char_routine*******************

get_char

            call scan_keypad

            MOVWF PORTD ; SENDING DATA TO PORTD FOR GLOWING LED'S

            ADDLW 0x30            ;converting hex to ascii

RETLW

***********************SCAN_KEYPAD ROUTINE**************

 

scan_keypad               ;THIS IS THE ROUTINE FOR SCANNING THE KEYPAD AND RETURNING THE VALUE IN W REGISTER

K1:      MOVLW EEh ; (1110 1110) FOR 1

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING BACK FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,4,0      ;BIT 4 IS MADE LOW

            BTFSS W,0,0  ;BIT 0 IS CHECKED IF ITS 1

            RETLW EEh

            GOTO K2

K2:

            MOVLW EDh ; (1110 1101) FOR 2

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,4,0      ;BIT 4 IS MADE LOW

            BTFSS W,1,0  ;BIT 1 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW EDh

            GOTO K3

K3:

            MOVLW ECh ; (1110 1011) FOR 3

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,4,0      ;BIT 4 IS MADE LOW

            BTFSS W,2,0  ;BIT 2 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW ECh

            GOTO K4

K4:

            MOVLW E7h ; (1110 0111) FOR A or '+'

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,4,0      ;BIT 4 IS MADE LOW

            BTFSS W,3,0  ;BIT 3 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW E7h

            GOTO K5

K5:

            MOVLW DEh ; (1101 1110) FOR 4

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,5,0      ;BIT 5 IS MADE LOW

            BTFSS W,0,0  ;BIT 0 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW DEh

            GOTO K6

K6:

            MOVLW DDh ; (1101 1101) FOR 5

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,5,0      ;BIT 5 IS MADE LOW

            BTFSS W,1,0  ;BIT 1 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW DDh

            GOTO K7

K7:

            MOVLW DBh ; (1101 1011) FOR 6

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,5,0      ;BIT 5 IS MADE LOW

            BTFSS W,2,0  ;BIT 2 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW DBh

            GOTO K8

K8:

            MOVLW D7h ; (1101 0111) FOR B or '-'

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,5,0      ;BIT 5 IS MADE LOW

            BTFSS W,3,0  ;BIT 3 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW D7h

            GOTO K9

K9:

            MOVLW BEh ; (1011 1110) FOR 7

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,6,0      ;BIT 6 IS MADE LOW

            BTFSS W,0,0  ;BIT 0 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW BEh

            GOTO K10

K10:

            MOVLW BDh ; (1011 1101) FOR 8

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,6,0      ;BIT 6 IS MADE LOW

            BTFSS W,1,0  ;BIT 1 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW BDh

            GOTO K11

K11:

            MOVLW BBh ; (1011 1011) FOR 9

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,6,0      ;BIT 6 IS MADE LOW

            BTFSS W,2,0  ;BIT 2 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW BBh

            GOTO K12

K12:

            MOVLW B7h ; (1011 0111) FOR C or '*'

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,6,0      ;BIT 6 IS MADE LOW

            BTFSS W,3,0  ;BIT 3 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW B7h

            GOTO K13

K13:

            MOVLW 7Eh ; (0111 1110) FOR *

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,7,0      ;BIT 7 IS MADE LOW

            BTFSS W,0,0  ;BIT 0 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW 7Eh

            GOTO K14

K14:

            MOVLW 7Dh ; (0111 1101) FOR 0

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,7,0      ;BIT 7 IS MADE LOW

            BTFSS W,1,0  ;BIT 1 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW 7Dh

            GOTO K15

K15:

            MOVLW 7Bh ; (0111 1011) FOR #

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,7,0      ;BIT 7 IS MADE LOW

            BTFSS W,2,0  ;BIT 2 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW 7Bh

            GOTO K16

K16:

            MOVLW 77h ; (0111 0111) FOR D or 'C' for clear

            MOVWF PORTC       ; COPYING DATA TO PORT C

            MOVF PORTC,W ;READING COLUMNS FROM PORTC AND COPYING DATA IN W REGISTERS

            BCF W,7,0      ;BIT 7 IS MADE LOW

            BTFSS W,3,0  ;BIT 3 IS CHECKED IF ITS 1 NEXT INSTRUCTION WILL BE SKIPPED

            RETLW 77h

            GOTO K17                

K17:

            RETLW 0FFh ; RETURN 0XFF IF NOTHING IS PRESSED

***********************SCAN_KEYPAD ROUTINE ENDS**********************

******DELAY SUBROUTINE*************

DELAY

            DECFSZ COUNT,1

RETURN

end

 END


Related Discussions:- Program for dispaying lcd characters

Write an assembly program to find out largest number, Program :  Write an...

Program :  Write an assembly program to find out the largest number from a given unordered array of 8-bit numbers that stored in the locations starting from a known address. S

The processor 8088-microprocessor, The processor 8088 The launching of ...

The processor 8088 The launching of the processor 8086 is consider as a remarkable step in the development of high speed computing machines. Before the introduction  of 8086 mo

Mmm development board, Write an account of your findings and produce a repo...

Write an account of your findings and produce a report containing all aspects of the above. Include a step-by-step 'simple User Guide' so that your program can be operated as inten

Explore debugger, add the contents of the defined memory locations 120, 133...

add the contents of the defined memory locations 120, 133, 122 using mov instruction in dosbox

Hold response sequence-microprocesssor, Hold Response Sequence The HOLD...

Hold Response Sequence The HOLD pin is examined at leading edge of each clock pulse. If it is received active line by the processor before T4 of the earlier cycle/during the T1

Cisc characteristics-microprocessor, CISC Characteristics : The design...

CISC Characteristics : The design of an instruction  set for a computer  might take into consideration  not only machine language constraints,  but  also  the  requirements  i

Develop an assembly language program, • To develop an assembly language pro...

• To develop an assembly language program to control a "simulated" intelligent domestic lighting system with the intention of deterring burglary. • To produce a schematic circuit d

Addressing modes for sequential control-microprocessor, The addressing mode...

The addressing modes for the sequential control transfer instructions are described below:   1. Immediate: Immediate data is a part of instruction,in this type of addressin

8088 timing system diagram-Microprocessor, 8088  Timing System Diagram ...

8088  Timing System Diagram The 8088 address/data  bus is divided  in 3 parts (a) the lower 8 address/data  bits, (b) the middle 8 address bits, and (c) the upper 4 status/

Execution unit and bus interface unit-microprocessor, Execution Unit (EU) a...

Execution Unit (EU) and Bus Interface Unit (BIU) : 8086 consist of two processors called EU and BIU. Two Processors can work parallel. This improves speed of execution. BIU fi

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd