📄 lm032l.lst
字号:
MPASM 01.40 Released LM032L.ASM 1-22-1997 10:25:15 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 LIST P=16C64
00002 ERRORLEVEL -302
00003 ;
00004 ; This program interfaces to a Hitachi (LM032L) 2 line by 20 character display
00005 ; module. The program assembles for either 4-bit or 8-bit data interface, depending
00006 ; on the value of the 4bit flag. LCD_DATA is the port which supplies the data to
00007 ; the LM032L, while LCD_CNTL is the port that has the control lines ( E, RS, RW ).
00008 ; In 4-bit mode the data is transfer on the high nibble of the port ( PORT<7:4> ).
00009 ;
00010 ; Program = LM032L.ASM
00011 ; Revision Date: 5-10-94
00012 ; 1-22-97 Compatibility with MPASMWIN 1.40
00013 ;
00014 ;
00015 include <p16c64.inc>
00001 LIST
00002 ; P16C64.INC Standard Header File, Version 1.01 Microchip Technology, Inc.
00238 LIST
00016
0000009F 00017 ADCON1 EQU 9F
00018
00000000 00019 FALSE EQU 0
00000001 00020 TRUE EQU 1
00021
00022 include <lm032l.h>
00069 list
00023 ;
00000001 00024 Four_bit EQU TRUE ; Selects 4- or 8-bit data transfers
00000000 00025 Data_HI EQU FALSE ; If 4-bit transfers, Hi or Low nibble of PORT
00026 ;
00027 ;
00028 if ( Four_bit && !Data_HI )
00029 ;
00000006 00030 LCD_DATA EQU PORTB
00000086 00031 LCD_DATA_TRIS EQU TRISB
00032 ;
00033 else
00034 ;
00035 LCD_DATA EQU PORTD
00036 LCD_DATA_TRIS EQU TRISD
00037 ;
00038 endif
00039 ;
00000005 00040 LCD_CNTL EQU PORTA
00041 ;
00042 ;
00043 ;
00044 ; LCD Display Commands and Control Signal names.
00045 ;
00046 if ( Four_bit && !Data_HI )
00047 ;
00000000 00048 E EQU 0 ; LCD Enable control line
00000001 00049 RW EQU 1 ; LCD Read/Write control l
MPASM 01.40 Released LM032L.ASM 1-22-1997 10:25:15 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
ine
00000002 00050 RS EQU 2 ; LCD Register Select cont
rol line
00051 ;
00052 else
00053 ;
00054 E EQU 3 ; LCD Enable control line
00055 RW EQU 2 ; LCD Read/Write control l
ine
00056 RS EQU 1 ; LCD Register Select cont
rol line
00057 ;
00058 endif
00059 ;
00060 ;
00000030 00061 TEMP1 EQU 0x030
00062 ;
0000 00063 org RESET_V ; RESET vector location
0000 2808 00064 RESET GOTO START ;
00065 ;
00066 ; This is the Periperal Interrupt routine. Should NOT get here
00067 ;
MPASM 01.40 Released LM032L.ASM 1-22-1997 10:25:15 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00068 page
0004 00069 org ISR_V ; Interrupt vector location
0004 00070 PER_INT_V
0004 1283 00071 ERROR1 BCF STATUS, RP0 ; Bank 0
0005 1407 00072 BSF PORTC, 0
0006 1007 00073 BCF PORTC, 0
0007 2804 00074 GOTO ERROR1
00075 ;
00076 ;
00077 ;
0008 00078 START ; POWER_ON Reset (Beginning of program)
0008 0183 00079 CLRF STATUS ; Do initialization (Bank 0)
0009 018B 00080 CLRF INTCON
000A 018C 00081 CLRF PIR1
000B 1683 00082 BSF STATUS, RP0 ; Bank 1
000C 3000 00083 MOVLW 0x00 ; The LCD module does not like to work w/ weak pull-ups
000D 0081 00084 MOVWF OPTION_REG ;
000E 018C 00085 CLRF PIE1 ; Disable all peripheral interrupts
000F 30FF 00086 MOVLW 0xFF ;
Warning[219]: Invalid RAM location specified.
0010 009F 00087 MOVWF ADCON1 ; Port A is Digital.
00088 ;
00089 ;
0011 1283 00090 BCF STATUS, RP0 ; Bank 0
0012 0185 00091 CLRF PORTA ; ALL PORT output should output Low.
0013 0186 00092 CLRF PORTB
0014 0187 00093 CLRF PORTC
0015 0188 00094 CLRF PORTD
0016 0189 00095 CLRF PORTE
0017 1010 00096 BCF T1CON, TMR1ON ; Timer 1 is NOT incrementing
00097 ;
0018 1683 00098 BSF STATUS, RP0 ; Select Bank 1
0019 0185 00099 CLRF TRISA ; RA5 - 0 outputs
001A 30F0 00100 MOVLW 0xF0 ;
001B 0086 00101 MOVWF TRISB ; RB7 - 4 inputs, RB3 - 0 outputs
001C 0187 00102 CLRF TRISC ; RC Port are outputs
001D 1407 00103 BSF TRISC, T1OSO ; RC0 needs to be input for the oscillator to function
001E 0188 00104 CLRF TRISD ; RD Port are outputs
001F 0189 00105 CLRF TRISE ; RE Port are outputs
0020 140C 00106 BSF PIE1, TMR1IE ; Enable TMR1 Interrupt
0021 1781 00107 BSF OPTION_REG,NOT_RBPU ; Disable PORTB pull-ups
0022 1283 00108 BCF STATUS, RP0 ; Select Bank 0
00109 ;
MPASM 01.40 Released LM032L.ASM 1-22-1997 10:25:15 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00110 page
00111 ;
00112 ; Initilize the LCD Display Module
00113 ;
0023 0185 00114 CLRF LCD_CNTL ; ALL PORT output should output Low.
00115
0024 00116 DISPLAY_INIT
00117 if ( Four_bit && !Data_HI )
0024 3002 00118 MOVLW 0x02 ; Command for 4-bit interface low nibble
00119 endif
00120 ;
00121 if ( Four_bit && Data_HI )
00122 MOVLW 0x020 ; Command for 4-bit interface high nibble
00123 endif
00124 ;
00125 if ( !Four_bit )
00126 MOVLW 0x038 ; Command for 8-bit interface
00127 endif
00128 ;
0025 0086 00129 MOVWF LCD_DATA ;
0026 1405 00130 BSF LCD_CNTL, E ;
0027 1005 00131 BCF LCD_CNTL, E ;
00132 ;
00133 ; This routine takes the calculated times that the delay loop needs to
00134 ; be executed, based on the LCD_INIT_DELAY EQUate that includes the
00135 ; frequency of operation. These uses registers before they are needed to
00136 ; store the time.
00137 ;
0028 3006 00138 LCD_DELAY MOVLW LCD_INIT_DELAY ;
0029 00B3 00139 MOVWF MSD ; Use MSD and LSD Registers to Initilize LCD
002A 01B4 00140 CLRF LSD ;
002B 0BB4 00141 LOOP2 DECFSZ LSD, F ; Delay time = MSD * ((3 * 256) + 3) * Tcy
002C 282B 00142 GOTO LOOP2 ;
002D 0BB3 00143 DECFSZ MSD, F ;
002E 00144 END_LCD_DELAY
002E 282B 00145 GOTO LOOP2 ;
00146 ;
00147 ; Command sequence for 2 lines of 5x7 characters
00148 ;
002F 00149 CMD_SEQ
00150 ;
00151 if ( Four_bit )
00152 if ( !Data_HI )
002F 3002 00153 MOVLW 0X02 ; 4-bit low nibble xfer
00154 else
00155 MOVLW 0X020 ; 4-bit high nibble xfer
00156 endif
00157 ;
00158 else ; 8-bit mode
00159 MOVLW 0X038
00160 endif
00161 ;
0030 0086 00162 MOVWF LCD_DATA ; This code for both 4-bit and 8-bit modes
MPASM 01.40 Released LM032L.ASM 1-22-1997 10:25:15 PAGE 5
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0031 1405 00163 BSF LCD_CNTL, E ;
0032 1005 00164 BCF LCD_CNTL, E ;
00165 ;
00166 if ( Four_bit ) ; This code for only 4-bit mode (2nd xfer)
00167 if ( !Data_HI )
0033 3008 00168 MOVLW 0x08 ; 4-bit low nibble xfer
00169 else
00170 MOVLW 0x080 ; 4-bit high nibble xfer
00171 endif
0034 0086 00172 MOVWF LCD_DATA ;
0035 1405 00173 BSF LCD_CNTL, E ;
0036 1005 00174 BCF LCD_CNTL, E ;
00175 endif
00176 ;
00177 ; Busy Flag should be valid after this point
00178 ;
0037 300C 00179 MOVLW DISP_ON ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -