📄 l6f877 lcd.asm
字号:
; Aquamate, gestion d'un aquarium marin
; Copyright (C) Julien Schmitt
; julien@jls-info.com
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2
; of the License, or (at your option) any later version.
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
LIST p=16F877
ERRORLEVEL -305, -306, -302
#include "P16F877.INC"
#define E PORTB,0
#define RW PORTB,1
#define RS PORTB,2
#define CLK PORTE,0
#define IO PORTE,1
#define RST PORTE,2
;Sorties I2C :
;composant 0 : BLANCHE,BLEUE,1,2,3,4,TERMO,LIBRE
;composant 1 : REAC,NIV,OSMO
;Entrees I2C
BAC_BAS equ 03h
BAC_HAUT equ 04h
RES_BAS equ 05h
RES_HAUT equ 06h
;RAM
CBLOCK 20h
TEMP1
TEMP2
TEMP3
TEMP4
TEMP5
DONNEE
MENUPOS
PB
ADRESSE
MAX
FLAGS
EXDONNEE
HEURES
MINUTES
SECONDES
SORTIES
SORTIES1
FINRETRO
REMPREAC
M_REAC
H_REAC
M_REMP
EXSECONDES
CMDMANU
CPT
CPT2
CPT_MIN
CMDMANU1
EXDONNEE2
CPT_TIMER
TEMPERATURE_ENTIER
TEMPERATURE_DECIMALE
FIN_X
ENDC
CBLOCK 70H ; 70H - 7FH : accessible depuis toutes les banks
W_TEMP
STATUS_TEMP
ENDC
;EEPROM
L_BLANCHE equ 00h ;heures debut - minutes debut -
L_BLEUE equ 04h ;heures fin - minutes fin
REACTEUR equ 08h ;toutes les X heures - pendant X min
REMPLISSAGE equ 0Ah ;toutes les X minutes - pendant X sec
POMPE1 equ 0Ch ;
POMPE2 equ 0Fh ;24 bits par pompe pour avoir les
POMPE3 equ 12h ;24 heures
POMPE4 equ 15h ;
REACTEUR2 equ 18h ;toutes les X minutes - pendant X min
H_REMPLISS equ 20h ;comme L_BLANCHE
TEMP_VISEE equ 24h ;seuil bas - seuil haut (4 octets)
TEMPS_REBOND equ 18h ;X fois 6 ms
HYSTERESIS equ d'1'
ORG 0003h
goto MAIN
;****************************************************************************
; interruption
;****************************************************************************
ORG 0004h
goto INT
;****************************************************************************
; TEMPO == attente : 1 dans W = 0,25 ms
;****************************************************************************
TEMPO
movwf TEMP1
tempo2
movlw 0ACh
movwf TEMP2
tempo1
clrwdt
decfsz TEMP2
goto tempo1
decfsz TEMP1
goto tempo2
retlw 0
;****************************************************************************
; Pilotage LCD
; LCDCMD envoie la commande W au LCD
; LCDCHAR envoie le caractere W au LCD
;****************************************************************************
LCDCMD
bcf INTCON,GIE
movwf TEMP1
call LCDBUSY
bcf RS
goto lcdwr
LCDCHAR
bcf INTCON,GIE
movwf TEMP1
call LCDBUSY
bsf RS
lcdwr
clrwdt
bcf RW
bsf E
movf TEMP1,W
movwf PORTD
bcf E
bsf INTCON,GIE
retlw 0
;****************************************************************************
; LCDSTR == envoie la chaine W au LCD
;****************************************************************************
LCDSTR
movwf TEMP3
movlw HIGH(MSG)
movwf PCLATH
movf TEMP3,W
call MSG
clrf PCLATH
andlw 0FFH
btfsc STATUS,Z
retlw 0
call LCDCHAR
incf TEMP3,W
goto LCDSTR
;****************************************************************************
; LCDSTR2 == envoie la chaine W au LCD
;****************************************************************************
LCDSTR2
movwf TEMP3
movlw HIGH(MSG2)
movwf PCLATH
movf TEMP3,W
call MSG2
clrf PCLATH
andlw 0FFH
btfsc STATUS,Z
retlw 0
call LCDCHAR
incf TEMP3,W
goto LCDSTR2
;****************************************************************************
; LCDBUSY == attend que le LCD soit libre
;****************************************************************************
LCDBUSY
bcf INTCON,GIE
bsf STATUS,RP0
movlw 0xFF
movwf TRISD
bcf STATUS,RP0
bcf RS
bsf RW
bsf E
movf PORTD,W
bcf E
andlw 0x80
btfss STATUS,Z
goto LCDBUSY
bcf RW
bsf STATUS,RP0
clrf TRISD
bcf STATUS,RP0
bsf INTCON,GIE
return
;****************************************************************************
; LCDDEC == ecrit W en decimal
;****************************************************************************
LCDDEC
clrf TEMP2
movwf TEMP3
lcddec10
movlw 0Ah
subwf TEMP3,W
btfss STATUS,C
goto decend
movwf TEMP3
incf TEMP2
goto lcddec10
decend
movf TEMP2,W
addlw 30h
call LCDCHAR
movf TEMP3,W
addlw 30h
goto LCDCHAR
;****************************************************************************
; LCDHEX == ecrit W en Hexadecimal
;****************************************************************************
LCDHEX
movwf TEMP3
swapf TEMP3,W
call WRITEDIG
movf TEMP3,W
WRITEDIG
andlw 0Fh
addlw 0F6h
btfsc STATUS,C
addlw 07h
addlw 3Ah
goto LCDCHAR
;****************************************************************************
; LCDSETADR == chargement de l'adresse
;****************************************************************************
LCDSETADR
iorlw 80h
call LCDCMD
retlw 0
;****************************************************************************
; LCDINIT
;****************************************************************************
LCDINIT
bcf RW
bcf E
bcf RS
movlw 80h
call TEMPO
movlw 38h ;interface 8 bits, 2 lignes
call LCDCMD
movlw 08h ;disp.off, curs.off, no-blink
call LCDCMD
movlw 01h ;clear display
call LCDCMD
movlw 0Ch ;disp.on, curs.off
call LCDCMD
movlw 06h ;auto-inc (shift-cursor)
call LCDCMD
return
;****************************************************************************
; DS1302 == lecture/ecriture
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -