PIC microcontroller LCD1602 display

Publisher:JoyfulSpiritLatest update time:2017-12-07 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

P IC  single chip  LCD 1602 displays the website address and phone number

;************************************
PCL EQU 2H ;Define the low byte address of program memory
STATUS EQU 3H ;Define the status register address
PORTD EQU 8H ;Define the RD port data register address

PORTC EQU 7H ;define the address of RC port data register
TRISD EQU 88H ;define the address of RD port direction control register
TRISC EQU 87H ;define the address of RC port direction control register
ADCON1 EQU 9FH ;define the address of ADC module control register 1
;********************
Z EQU 2 ;define the address of 0 status bit
RP0 EQU 5 ;define the address of page select bit RP0
;************************
RS EQU 2 ;LCD register select signal pin is defined at RD.2 pin
RW EQU 1 ;LCD read/write signal pin is defined at RD.1 pin
E EQU 0 ;LCD chip select signal pin is defined at RD.0 pin
COUNT EQU 24H ;define the address of count register
TMP1 EQU 25H ;define the address of temporary register
;**********************
  ORG 000H
  NOP ;place a null operation instruction
  GOTO MAIN
  ORG required by ICD 0008H
;******************************************************
TABLE ;Get the display code of the first line WWW.PICAVR.COM 
  ADDWF PCL,1 ;Address offset plus current PC value
  RETLW 20H ;Space
  RETLW 57H ;W
  RETLW 57H ;W
  RETLW 57H ;W
  RETLW 2EH ;.


  RETLW 50H ;P
  RETLW 49H ;I
  RETLW 43H ;C
  RETLW 41H ;A
  RETLW 56H ;V
  RETLW 52H ;R

  RETLW 2EH ;.
  RETLW 43H ;C
  RETLW 4FH ;O
  RETLW 4DH ;M
  RETLW 20H ;SpaceRETLW
  00H
;-------------------- ----------------------------------
TABLE1 ;Get the display code of the second lineTEL:020-86307727
  ADDWF PCL,1 ;Address offset plus current PC valueRETLW                                                  
  54H ;T 
  RETLW 45H ;E                             
  RETLW 4CH ;L
  RETLW 3AH ;:

  RETLW 30H ;0
  RETLW 32H ;2
  RETLW 30H ;0

  RETLW 0B0H ;-
  RETLW 38H ;8
  RETLW 36H ;6
  RETLW 33H ;3
  RETLW 30H ;0
  RETLW 37H ;7
  RETLW 37H ;7
  RETLW 32H ;2
  RETLW 37H ;7
  RETLW 20H ;space
  RETLW 00H
;******* ************************************************
MAIN

  BSF STATUS,RP0          
  MOV LW 07H
  MOV WF ADCON1 ; Set RA port to normal digital IO port
  MOV LW 00H
  MOV WF TRISD ; Define RD port and RC port to output
  MOV WF TRISC
  BCF STATUS,RP0

  CALL DELAY ;Call delay, LCD reset may not be as fast as PIC when powered on
  MOV LW 01H
  MOV WF PORTC ;Clear screen
  CALL ENABLE
  MOV LW 38H
  MOV WF PORTC ;8-bit 2-line 5x7 dot matrix
  CALL ENABLE
  MOV LW 0FH ;Display, cursor, and blinking turned on
  MOV WF PORTC
  CALL ENABLE
  MOV LW 06H ;Text does not move, cursor automatically moves right
  MOV WF PORTC             
  CALL ENABLE

  MOV LW 80H
  MOV WF PORTC ; Display position
  CALL ENABLE


  CALL WRITE1 ;Call the subroutine to send the first line of numbers "WWW.PICAVR.COM"
  MOV LW 0C0H
  MOV WF PORTC ;The location of the first line       
  CALL ENABLE
  CALL WRITE2 ;Call the subroutine to send the second line of numbers "TEL:020-86307727"
  CALL ENABLE
  GOTO $
  
;************************
WRITE1
  CLRF COUNT ;Send the first line of numbers
WRITE_A
  MOV FW COUNT
  CALL TABLE
  MOV WF TMP1
  CALL WRITE3
  INCF COUNT,1
  MOV FW TMP1
  XORLW 00H
  BTFSS STATUS,Z
  GOTO WRITE_A
  RETLW 0
;****************************
WRITE2 ;Send the second line of numbers
  CLRF COUNT
WRITE2_A
  MOV FW COUNT
  CALL TABLE1
  MOV WF TMP1
  CALL WRITE3
  INCF COUNT,1
  MOV FW TMP1
  XORLW 00H
  BTFSS STATUS,Z
  GOTO WRITE2_A
  RETLW 0
;**************************
WRITE3 ;Send data to LCD subroutine
  MOV WF PORTC
  BSF PORTD,RS
  BCF PORTD,RW
  BCF PORTD,E
  CALL DELAY
  BSF PORTD,E
  RETLW 0
;***********************************************
ENABLE
  BCF PORTD,RS ;Write control command subroutine
  BCF PORTD,RW
  BCF PORTD,E
  CALL DELAY
  BSF PORTD,E
  RETLW 0
;************************************************
DELAY                       
                             ;Subroutine name, also subroutine entry address
       MOV lw 0ffh ;Send the outer loop parameter value FFH through W MOV wf 20h ;to the 20H unit lp0
       used as the outer loop variable
MOV lw 0ffh ; pass the inner loop parameter value FFH through W
       MOV wf 21h ; send it to the 21H unit used as the inner loop variable
lp1 decfsz 21h,1 ; decrement the content of variable 21H, if it is 0, jump to
       goto lp1 ; jump to LP1
       decfsz 20h,1 ; decrement the content of variable 20H, if it is 0, jump
       to goto lp0 ; jump to LP0
       return ; return to the main program
       end ; end of source program


Reference address:PIC microcontroller LCD1602 display

Previous article:PIC microcontroller AD conversion LED display program
Next article:PIC microcontroller LCD1602 displays a single letter A program

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号