📄 term.asm
字号:
; ----------------- display buffer for all positive --------------------
;
; Characters written to CGRAM:
;
; -
; - -
; - - -
; - - - -
; - - - - -
; - - - - - -
; - - - - - - -
; - - - - - - - -
positive:
;User defined character 0
call Send0
call Send0
call Send0
call Send0
call Send0
call Send0
call Send0
call Send31
;User defined character 1
call Send0
call Send0
call Send0
call Send0
call Send0
call Send0
call Send31
call Send31
;User defined character 2
call Send0
call Send0
call Send0
call Send0
call Send0
call Send31
call Send31
call Send31
;User defined character 3
call Send0
call Send0
call Send0
call Send0
call Send31
call Send31
call Send31
call Send31
;User defined character 4
call Send0
call Send0
call Send0
call Send31
call Send31
call Send31
call Send31
call Send31
;User defined character 5
call Send0
call Send0
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
;User defined character 6
call Send0
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
;User defined character 7
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
movlw 0x08 ; correction for display
movwf Odjem
return
; ----------------- display buffer for all negtive --------------------
;
; Characters written to CGRAM:
;
; - - - - - - - -
; - - - - - - -
; - - - - - -
; - - - - -
; - - - -
; - - -
; - -
; -
negative:
;User defined character 0
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
;User defined character 1
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
call Send0
;User defined character 2
call Send31
call Send31
call Send31
call Send31
call Send31
call Send31
call Send0
call Send0
;User defined character 3
call Send31
call Send31
call Send31
call Send31
call Send31
call Send0
call Send0
call Send0
;User defined character 4
call Send31
call Send31
call Send31
call Send31
call Send0
call Send0
call Send0
call Send0
;User defined character 5
call Send31
call Send31
call Send31
call Send0
call Send0
call Send0
call Send0
call Send0
;User defined character 6
call Send31
call Send31
call Send0
call Send0
call Send0
call Send0
call Send0
call Send0
;User defined character 7
call Send31
call Send0
call Send0
call Send0
call Send0
call Send0
call Send0
call Send0
movlw 0x00 ; correction for display
movwf Odjem
return
;--------------------------------------------------------------------------------------------
; This function draws a diagram of the temperature in the past
; hours based on the values stored in the buffer at 0x1F
Diagram:
movlw 0x10
movwf Licznik
movlw 0x1F
movwf FSR
nloop:
movf INDF,w
movwf Temp
call GetRange
movwf Temp ; now Temp contains the range (0...15)
movf Odjem,w ; Odjem contains the correction
subwf Temp,f ; the correction is made: Temp=Temp-Odjem
btfsc Temp,5 ; check range
goto tosmall
btfsc Temp,6
goto tosmall
btfsc Temp,7
goto tosmall
btfsc Temp,3
goto tomuch
btfsc Temp,4
goto tomuch
goto ok
tomuch:
movlw 0x07
movwf Temp
goto ok
tosmall:
movlw 0x00
movwf Temp
ok:
movf Temp,w
call Send_Char
incf FSR,f
decfsz Licznik,f
goto nloop
return
;--------------------------------------------------------------------------------------------
; This function gets the range of the temperature:
; Range 0 -40...-35 deg and below
; 1 -35...-30 deg
; 2 -30...-25 deg
; 3 -25...-20 deg
; 4 -20...-15 deg
; 5 -15...-10 deg
; 6 -10...-05 deg
; 7 -05...-00 deg
; 8 +00...+05 deg
; 9 +05...+10 deg
; 10 +10...+15 deg
; 11 +15...+20 deg
; 12 +20...+25 deg
; 13 +25...+30 deg
; 14 +30...+35 deg
; 15 +35...+40 deg and over
;
; The input temperature is in variable Temp
; The function returns the range in W
;
; This function has to be updated if temperature
; table at 0x300 changes!!!
GetRange:
bcf STATUS,C ; clear carry
movf Temp,w ; < -20
addlw d'37' ; (256-219=...)
btfsc STATUS,C
retlw 0x03
movf Temp,w ; -20...-15
addlw d'74' ; (256-182=...)
btfsc STATUS,C
retlw 0x04
movf Temp,w ; -15...-10
addlw d'104' ; (256-152=...)
btfsc STATUS,C
retlw 0x05
movf Temp,w ; -10...-5
addlw d'132' ; (256-124=...)
btfsc STATUS,C
retlw 0x06
movf Temp,w ; -5...0
addlw d'155' ; (256-101=...)
btfsc STATUS,C
retlw 0x07
movf Temp,w ; 0...+5
addlw d'173' ; (256-83=...)
btfsc STATUS,C
retlw 0x08
movf Temp,w ; +5...+10
addlw d'189' ; (256-67=...)
btfsc STATUS,C
retlw 0x09
movf Temp,w ; +10...+15
addlw d'204' ; (256-52=...)
btfsc STATUS,C
retlw 0x0A
movf Temp,w ; +15...+20
addlw d'217' ; (256-39=...)
btfsc STATUS,C
retlw 0x0B
movf Temp,w ; +20...+25
addlw d'228' ; (256-28=...)
btfsc STATUS,C
retlw 0x0C
movf Temp,w ; +25...+30
addlw d'238' ; (256-18)
btfsc STATUS,C
retlw 0x0D
movf Temp,w ; +30...+35
addlw d'248' ; (256-8)
btfsc STATUS,C
retlw 0x0E
retlw 0x0F ; >+35
;--------------------------------------------------------------------------------------------
Wait_Busy:
; This function should read the Busy Flag of the LCD, but a long delay is OK
; as the program does not have to be speed-optimized
call Delay4100
return
;--------------------------------------------------------------------------------------------
Send_Char:
movwf Char ; Character to be sent is in W
call Wait_Busy ; Wait for LCD to be ready
movlw 0x0f
andwf PORTB,F ; Clear the upper nibble
movf Char,w
andlw 0xF0 ; Get upper nibble
iorwf PORTB,F ; Send data to LCD
bcf PORTA, R_W ; Set LCD to write
bsf PORTA, RS ; Set LCD to data mode
bsf PORTA, E ; toggle E for LCD
bcf PORTA, E
movlw 0x0f
andwf PORTB,F ; Clear the upper nibble
swapf Char,W
andlw 0xF0 ; Get lower nibble
iorwf PORTB,F ; Send data to LCD
bsf PORTA, E ; toggle E for LCD
bcf PORTA, E
return
;--------------------------------------------------------------------------------------------
Send0:
movlw 0x0
call Send_Char
return
;--------------------------------------------------------------------------------------------
Send31:
movlw 0x1F
call Send_Char
return
;--------------------------------------------------------------------------------------------
Send_Cmd:
movwf Char ; Character to be sent is in W
call Wait_Busy ; Wait for LCD to be ready
movlw 0x0f
andwf PORTB,F ; Clear the upper nibble
movf Char,w
andlw 0xF0 ; Get upper nibble
iorwf PORTB,F ; Send data to LCD
bcf PORTA,R_W ; Set LCD to write
bcf PORTA,RS ; Set LCD to command mode
bsf PORTA,E ; toggle E for LCD
bcf PORTA,E
movlw 0x0f
andwf PORTB,F ; Clear the upper nibble
swapf Char,W
andlw 0xF0 ; Get lower nibble
iorwf PORTB,F ; Send data to LCD
bsf PORTA,E ; toggle E for LCD
bcf PORTA,E
return
;--------------------------------------------------------------------------------------------
; Initilize the LCD Display Module
;
LCD_Init:
bcf PORTA, E ; Clear all controll lines
bcf PORTA, RS
bcf PORTA, R_W
call Delay15000 ; Wait for 15ms for LCD to get powered up
movlw 0x0f
andwf PORTB,F ; Clear the upper nibble
movlw 0x030 ; Command for 4-bit interface high nibble
iorwf PORTB,F ; Send data to LCD
bsf STATUS, RP0 ; Select Register page 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -