十年專注單片機方案開發的方案公司英銳恩,分享基于PIC單片機的128*64(ST7920)的液晶PIC程序。英銳恩現提供服務產品涉及主控芯片:8位單片機、16位單片機、32位單片機及各類運算放大器等。
list p=16F84A ; list directive to define processor
#include ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _HS_OSC
; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.
;***** VARIABLE DEFINITIONS
cblock 0X0c
w_temp
status_temp
TEMP1
TEMP2
TEMP3
TEMP4
TEMP5
START
COM
HDATA
LDATA
DATA8
DATACOUNT
index:2
indexback;真實的表中的序號
endc
#define CS PORTA,0 ;又名RS腳.
#define SID PORTA,1 ;又名R/W腳.
#define SCLK PORTA,2 ;又名E腳.
;**********************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
main
MOVLW 00H
banksel TRISA
MOVWF TRISA
banksel PORTA
MOVLW 00H
MOVWF PORTA
;寫指令前,先對START賦值0XF8,寫數據前先對START賦值0XFA
pagesel INILCM
CALL INILCM
MOVLW 0XF8
banksel START
MOVWF START
MOVLW 0X80;設定DDRAM位址到位址計數器。
banksel COM
MOVWF COM
pagesel WRITE
CALL WRITE
MOVLW 0XFA
banksel START
MOVWF START
;*********************************用戶程序
;顯示全部文字:
movlw 0X00;從第0個數開始取數。
banksel index
MOVWF indexback
DISPLAYLOOP:
MOVLW 0X00
MOVWF index+1
MOVF indexback,0
MOVWF index
pagesel LWORDTABLE
call LWORDTABLE
banksel COM
MOVWF COM
pagesel WRITE
CALL WRITE
INCF indexback
movf indexback,0
ADDLW low(wordtablestart)
XORLW low(wordtableend)
SKPZ
GOTO DISPLAYLOOP
; MOVLW 0xb5
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xc4
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xc3
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xfb
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xd7
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xd6
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xbd
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xd0
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xba
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xab
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xc7
; MOVWF COM
; pagesel WRITE
; CALL WRITE
; MOVLW 0xef
;MOVWF COM
; pagesel WRITE
;CALL WRITE
;MOVLW 0xbb
;MOVWF COM
;pagesel WRITE
;CALL WRITE
; MOVLW 0xb3
; MOVWF COM
;pagesel WRITE
; CALL WRITE
;0xc4,0xc3,0xfb,0xd7,0xd6,0xbd,0xd0,0xba,0xab,0xc7,0xef,0xbb,0xb3
pagesel