📄 lm032l.lst
字号:
MPASM 03.80 Released LM032L.ASM 11-20-2005 18:21:09 PAGE 1
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00001 ;
00002 ; This program interfaces to a Hitachi (LM032L) 2 line by 20 character display
00003 ; module. The program assembles for 4-bit data interface. LCD_DATA is the port
00004 ; which supplies the data and LCD_CTRL the control lines ( E, RS, R_W ) to the
00005 ; LM032L.
00006 ; This program only handles the data though the high nibble.
00007 ;****************************************************************************
00008 ;* This file and the resulting compiled code copyright1993-96 Steve Lawther *
00009 ;* Use of any of this code requires Steve Lawther to have a credit *
00010 ;* within the source code. Commercial use of any of this code *
00011 ;* requires the permission of the author, Steve Lawther *
00012 ;* For more details read 'README.TXT' or email steve.lawther@gecm.com *
00013 ;****************************************************************************
00014
00015 include P16F628A.inc
00001 LIST
00002 ; P16F628A.INC Standard Header File, Version 1.10 Microchip Technology, Inc.
00265 LIST
00016 include tempdemo.inc
00001 ;****************************************************************************
00002 ;* *
00003 ;* Dallas 1 Wire Bus Temperature demo *
00004 ;* *
00005 ;****************************************************************************
00006
003D0900 00007 Clock_Freq equ d'4000000' ;4MHz - for wait macro calculations
00008
00009 udata_ovr 0x20 ;0x0C 16F84
0020 00010 DScommbuff res 1
0021 00011 DSCRC res 1
00012
0022 00013 tempone res 1
0023 00014 temptwo res 1
0024 00015 count res 1
0025 00016 count2 res 1 ; 2nd loop counter for nested loops
0026 00017 bits_byte res 1
00018
0027 00019 CHARBUF res 1
0028 00020 temp_hi res 1
0029 00021 temp_lo res 1
002A 00022 acc_lo res 1
002B 00023 acc_hi res 1
00024
002C 00025 vvshift res 1
00026
00027 #define PRESENCE_bit bits_byte, 0
00028 #define round00_bit bits_byte, 1
00029 #define DSNext_bit bits_byte, 2
00030 #define neg_temp_bit bits_byte, 3
00031 #define DALLAS_BUS PORTA, 4
00032
002D 00033 ROM_no res 8
0035 00034 id_bit_number res 1
MPASM 03.80 Released LM032L.ASM 11-20-2005 18:21:09 PAGE 2
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
0036 00035 last_zero res 1
0037 00036 LastDiscrepancy res 1
0038 00037 LastFamilyDiscr res 1
0039 00038 id_bits_byte res 1
003A 00039 rom_mask res 1
00040
00041 #define id_bit id_bits_byte, 0 ; first bit read in a search ID sequence
00042 #define cmp_id_bit id_bits_byte, 1 ; complement of id_bit
00043 #define test_bit id_bits_byte, 2 ; test id_bit & cmp_id_bit
00044
00045 #define last_device id_bits_byte, 6
00046 #define Direction id_bits_byte, 7
00017 include lm032l.inc
00048 list
00018 include wait.inc
00001
00002 #define Nanosec * D'1'
00003 #define Microsec * D'1000'
00004 #define Millisec * D'1000000'
00005 #define Seconds * D'1000000000'
00006
00007
00008 ;**************************************************************
00009 ;* The WAIT macro *
00010 ;* * VERSION 1.01 * *
00011 ;* called by Wait <time>, lesscycles *
00012 ;**************************************************************
00013 ;History
00014 ;1.00 - Original
00015 ;1.01 - Fixed bug with small even numbers giving an error message
00016
00017
00018 Wait macro time_ns, lesscycles ;time_ns gives the wait time required, in ns
00019 radix dec
00020 variable instruct_time_ns = (( 1 Seconds ) / (Clock_Freq / 4 ))
00021 local cycles
00022 variable cycles = ((time_ns) / instruct_time_ns) ;required delay in
00023 ;100ths of instructions
00024
00025 if (cycles < (lesscycles) )
00026 messg NOTE - negative delay time with lesscycles cycles (no code)
00027
00028 exitm
00029 else
00030 variable cycles = (cycles - (lesscycles))
00031 endif
00032
00033 if (cycles == 0)
00034 messg "WARNING - delay time less than 1 instructions"
00035
00036 nop
00037 exitm
00038 endif
MPASM 03.80 Released LM032L.ASM 11-20-2005 18:21:09 PAGE 3
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00039
00040 if (cycles > (255*(256*3 + 6) + 2 + 3))
00041 messg "ERROR : Too long a wait for the WAIT macro at present!!"
00042 exitm
00043 endif
00044
00045 ; messg Info - calculated number of cycles = #v(cycles)
00046
00047
00048 if (cycles > ((255*3)+5))
00049
00050 movlw ((cycles-5)/(256*3+6))
00051 call longdelay
00052
00053 ifndef INCLONGDELAY
00054 #define INCLONGDELAY
00055 endif
00056
00057 exitm
00058 endif
00059
00060 if ((cycles > 8 ) && (cycles < (255*3 + 5)))
00061
00062 movlw ((cycles-5)/3)
00063 call shortdelay
00064
00065 ifndef INCSHORTDELAY
00066 #define INCSHORTDELAY
00067 endif
00068
00069 exitm
00070 endif
00071
00072 if (cycles < 8)
00073 while ( cycles > 1 )
00074
00075 goto $+1 ;two cycle nop
00076
00077 cycles -=2
00078 endw
00079 endif
00080
00081 if (cycles > 0)
00082 nop
00083
00084 endif
00085 exitm
00086
00087 messg "ERROR - got to end of WAIT.MAC"
00088
00089 radix hex
00090 endm
00019
MPASM 03.80 Released LM032L.ASM 11-20-2005 18:21:09 PAGE 4
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00020 errorlevel -302 ;Eliminate bank warning
00021
00000006 00022 LCD_DATA EQU PORTB
00000086 00023 LCD_DATA_TRIS EQU TRISB
00000006 00024 LCD_CTRL EQU PORTB
00025
00026 #define LED PORTB, 0 ; LED - clear for lit, set for off
00027
00028 ; LCD Display Commands and Control Signal names.
00029 #define LCD_E LCD_CTRL,1 ; LCD Enable control line
00030 #define LCD_R_W LCD_CTRL,2 ; LCD Read/Write control line
00031 #define LCD_RS LCD_CTRL,3 ; LCD Register Select control line
00032
0000 00033 global DISPLAY_RESET, SEND_CHAR_W, SEND_CHAR, SEND_CMD_W
0000 00034 global LOAD_CGRAM, LOAD_CGRAM_LOC
0000 00035 extern longdelay, shortdelay ;DELAY.ASM
0000 00036 extern uchars ;TEMPDEMO.ASM
00037 ;
MPASM 03.80 Released LM032L.ASM 11-20-2005 18:21:09 PAGE 5
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00038 page
00039 ;
00040 ; Initilize the LCD Display Module
00041 ;****************************************************************************
00042 ;*
00043 ;* DISPLAY RESET
00044 ;*
00045 ;****************************************************************************
00046
00047 PROG CODE
00048
0000 00049 DISPLAY_RESET
00050 ;needs to have full routine to initialize corrupted display
00051 ;first setup lcd port - all outputs
00052
0000 1683 00053 bsf STATUS, RP0 ; Bank 1
0001 3000 00054 movlw b'00000000'
0002 0086 00055 movwf LCD_DATA_TRIS ;set all to output
0003 1283 00056 bcf STATUS, RP0 ; Bank 0
0004 0186 00057 clrf LCD_DATA ;set all port low
0005 1406 00058 bsf LED
00059 ;clrf LCDflags ;set to cmd next etc
00060 ;have to wait 15ms here
0006 0064 00061 clrwdt
00062 Wait 35 Millisec, 0
M radix dec
03E8 M variable instruct_time_ns = (( 1 Seconds ) / (Clock_Freq / 4 ))
0000 M local cycles
88B8 M variable cycles = ((35 * D'1000000') / instruct_time_ns) ;required delay in
M ;100ths of instructions
M
M if (cycles < (0) )
M messg NOTE - negative delay time with 0 cycles (no code)
M
M exitm
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -