LIST P=16F877A
#INCLUDE <P16F877A.INC>
__CONFIG 0X3F32
;===========================================================================================
; MACRO
;===========================================================================================
BANK0 MACRO ;CHANGE TO BANK 0
BCF STATUS,RP0
BCF STATUS,RP1
ENDM
BANK1 MACRO ;CHANGE TO BANK 1
BSF STATUS,RP0
BCF STATUS,RP1
ENDM
CLOCK_E MACRO ;'E' RISE UP N FALL DOWN
BSF PORTB,7
CALL DELAY1
BCF PORTB,7
CALL DELAY1
ENDM
;=========================================================================================
; RESET VECTOR
;=========================================================================================
ORG 00h
RESET GOTO INIT
;=========================================================================================
;INTERRUPT VECTOR
;=========================================================================================
ORG 04h
RETFIE
;=========================================================================================
; INITIALIAZATION OF I/O
;=========================================================================================
ORG 05h
INIT BANK1
CLRF TRISC
MOVLW B'00001110'
MOVWF TRISB
MOVLW B'00000001'
MOVWF TRISD
BANK0
CLRF PORTC
CLRF PORTD
CLRF PORTB
;=======================================================================================
;DELAY SUBROUTINE
;=======================================================================================
DELAY1 MOVLW FFh
MOVWF 20h
MOVLW FFh
MOVWF 21h
DELAYLOOP DECFSZ 20h
GOTO DELAYLOOP
DECFSZ 21h
GOTO DELAYLOOP
RETURN
;==============================================================================================
;MAIN PROGRAM START HERE
;==============================================================================================
;LCD INITIALIZED
CALL DELAY1
CALL DELAY1
BCF PORTB,6 ; R/S SET TO '0'as a command
MOVLW B'00110000'
MOVWF PORTC ; FUNCTION SET: 8 BIT INTERFACE
CLOCK_E ; E CLOCK MACRO
MOVLW B'00001101'
MOVWF PORTC ; DISPALY & CURSOR: SET TO DISPLAY ON; CURSOR UNDERLINE OFF; CURSOR BLINK ON
CLOCK_E ; E CLOCK MACRO
MOVLW B'00111000'
MOVWF PORTC ; FUNCTION SET: 8 BIT; 2 LINE MODE; 5X7 DOT FORMAT
CLOCK_E ; E CLOCK MACRO
MOVLW B'00000001'
MOVWF PORTC ; CLEAR DISPLAY
CLOCK_E ; E CLOCK MACRO
MOVLW B'00000110'
MOVWF PORTC ; CHARACTER ENTRY MODE: INCREMENT; DISPLAY SHIFT ON
CLOCK_E ; E CLOCK MACRO
;WRITE YOUR CHARACTER HERE
BSF PORTB,6 ;R/S SET TO '1' to write character
MOVLW B'01010110' ;'V'in ASCII mode
MOVWF PORTC ;Display 'V'
CLOCK_E
MOVLW B'01001111' ;'O' in ASCII mode
MOVWF PORTC ;Display 'O'
CLOCK_E
MOVLW B'01001100' ;'L' in ASCII mode
MOVWF PORTC ;Diplay 'L'
CLOCK_E
MOVLW B'01010101' ;'U' in ASCII mode
MOVWF PORTC ;Display 'U'
CLOCK_E
MOVLW B'01001101' ;'M' in ASCII mode
MOVWF PORTC ;Display 'M'
CLOCK_E
MOVLW B'01000101' ;'E' in ASCII mode
MOVWF PORTC ;Display 'E'
CLOCK_E
MOVLW B'00111010' ;':' in ASCII mode
MOVWF PORTC ;Display ':'
CLOCK_E
MOVLW ' ' ;' ' in ASCII mode
MOVWF PORTC ;Display ' '
CLOCK_E