LCD Programming with Assembly Language

By @baymuhendis4/21/2018programming

I think it is very useful code for engineering students. There are many resources on the internet for C programming, but there is no source in the assembly language. I share the project with you. I use PIC18F4520 microcontroller.

Simulation Picture.PNG

LIST P=18f4520
INCLUDE "P18f4520.INC"
ORG 0
CLRF PORTB
CLRF PORTD ;Clear PORTB and PORTB
CLRF TRISB
CLRF TRISD ;Select as PORTB and PORTD output
START
CALL LCD_Settings
CALL NAME
GOTO START
NAME
MOVLW 'F'
MOVWF PORTB
CALL LCD_Send
MOVLW 'A'
MOVWF PORTB
CALL LCD_Send
MOVLW 'T'
MOVWF PORTB
CALL LCD_Send
MOVLW 'I'
MOVWF PORTB
CALL LCD_Send
MOVLW 'H'
MOVWF PORTB
CALL LCD_Send
MOVLW ' '
MOVWF PORTB
CALL LCD_Send
MOVLW 'D'
MOVWF PORTB
CALL LCD_Send
MOVLW 'U'
MOVWF PORTB
CALL LCD_Send
MOVLW 'N'
MOVWF PORTB
CALL LCD_Send
MOVLW 'D'
MOVWF PORTB
CALL LCD_Send
MOVLW 'A'
MOVWF PORTB
CALL LCD_Send
MOVLW 'R'
MOVWF PORTB
CALL LCD_Send
RETURN
;LCD SETTINGS
R1 EQU 0X0A
R2 EQU 0X0B
R3 EQU 0X0C
;LCD Configuration
LCD_Settings
BCF PORTD,0 ; RS=0
CALL LCD_Command
MOVLW 0x0C ; Close Cursor
MOVWF PORTB
CALL LCD_Command
BSF PORTD, 0 ; RS=1
RETURN
;Send Command Subroutine
LCD_Command
BSF PORTD,1; E=1
BCF PORTD,1; E=0
CALL DELAY
RETURN
;Send Data Subroutine
LCD_Send
BSF PORTD,0 ; RS=1
CALL LCD_Command
RETURN
; Delay Subroutine
DELAY
MOVLW D'10'
MOVWF R3
LOOP MOVLW D'10'
MOVWF R2
LOOP_1 MOVLW D'10'
MOVWF R1
LOOP_2 NOP
DECF R1,F
BNZ LOOP_2
DECF R2,F
BNZ LOOP_1
DECF R3,F
BNZ LOOP
RETURN

END
1

comments