Program for dispaying lcd characters, Assembly Language

#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

Posted Date: 3/5/2013 4:24:41 AM | Location : United States







Related Discussions:- Program for dispaying lcd characters, Assignment Help, Ask Question on Program for dispaying lcd characters, Get Answer, Expert's Help, Program for dispaying lcd characters Discussions

Write discussion on Program for dispaying lcd characters
Your posts are moderated
Related Questions
Introduction to Microprocessor: Microprocessor works like a CPU in a microcomputer. It's present as a single IC chip in a microcomputer. Microprocessor is the soul of the machi

Port Mapped I/O or I/O Mapped I/O I/O devices are mapped into a separate address space. This is generally accomplished by having a different set of signal lines to denote a mem

write a programme the addition two 3*3 matrix and stored in from list

Comparison between 8086 and 8088 All the changes in 8088 above 8086 are indirectly or directly related to the 8-bit, 8085 compatible data and control bus interface. 1) The p


what is the hex value in ax after executing the instructions ax= 1E8A bx=4080 add al,bl sub ah,bh

how to store a bulk data in a external eeprom

Instruction set of 8086 : The 8086/8088 instructions are categorized into the following major types. This section describes the function of each of the instructions with approp

to find the matrix addition

Develop a suitable schematic circuit diagram of your system showing the interface between the PIC16F84 and the existing mains light & switch, including 5V derivation from the 240V