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

Adc-arithmetic instruction-microprocessor, ADC: Add with Carry:- This instr...

ADC: Add with Carry:- This instruction performs the similar operation a like ADD instruction, but adds the carry flag bit (which might be set as a result of the previous calculatio

#title., BINARY TO GRAY CONVERSION

BINARY TO GRAY CONVERSION

Program, wap proram for bthe addition of two 3*3 matrix

wap proram for bthe addition of two 3*3 matrix

Iret-loop-unconditional branch instruction-microprocessor, IRET : Return f...

IRET : Return from ISR:- When an interrupt service routine is called, before transferring control to it, the IP, CS  register and flag registers are stored in the stack to ment

Assembler directives and operators-microprocessor, Assembler Directives and...

Assembler Directives and Operators The major advantage of machine language programming is directly that the memory control is in the hands of the programmer, so that, he can be

Write an 8086 assembly program, Project Description: Write an 80x86 asse...

Project Description: Write an 80x86 assembly program that performs the following functions: Reads a set of integers from a file into an array. The data file name is to be

Project, I need some guidance on which project to make in assembly language...

I need some guidance on which project to make in assembly language

Intel''s 8237 dma controller-microprocessor, Intel's 8237 DMA controller : ...

Intel's 8237 DMA controller : 1) The 8237 contain 4 independent I/O channels 2) It contains 27 registers, 7 of which are system-wide registers and 5 for each channel. 3)

End-endp-assemblers directive-microprocessor, END : END of Program:- Th...

END : END of Program:- The END directive marks the ending of the assembly language program. When the assembler comes across this END directive, it avoided the source lines avai

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