#include
;__CONFIG_DEBUG_OFF&_CP_ALL&_WRT_HALF&_CPD_ON&_LVP_OFF&_BODEN_OFF&_PWRTE_ON&_WDT_OFF&_HS_OSC
;芯片配置字,看門狗關,上電延時開,掉電檢測關,低壓編程關,加密,4M晶體HS振蕩
#defineRSPORTA,5;命令/數(shù)據(jù)選擇
#DEFINERWPORTA,4;讀/寫選擇
#DEFINEEPORTA,3;使能信號
#DEFINEPSBPORTA,2;并口/串口選擇(H/L)
#DEFINERSTPORTA,0;復位信號
;-----------------------------------------------
LCD_XEQU30H;頁地址
LCD_YEQU31H;Y地址
COUNTEQU32H;循環(huán)計數(shù)用
COUNT1EQU33H;循環(huán)計數(shù)用
COUNT2EQU34H;循環(huán)計數(shù)用
COUNT3EQU35H
POINTEQU36H;查表偏移地址
POINT1EQU37H;查表偏移地址
POINT2EQU38H;查表偏移地址
POINT3EQU40H
TEMPEQU39H;臨時寄存器
TEMP1EQU3AH;臨時寄存器
;-----------------------------------------------
ORG0000H;復位地址
NOP;ICD需要的空指令
GOTOMAIN;跳轉到主程序
;**********************主程序************************
MAIN
BANKSELTRISA
CLRFTRISA;A口輸出
CLRFTRISD;D口輸出
BANKSELADCON1
MOVLW06H
MOVWFADCON1;A口全為數(shù)字口
CLRFSTATUS
BCFRST;復位LCD
CALLDELAY;延時一段時間
BSFRST;清除復位信號
NOP
BSFPSB;并口通訊
;**************************初始化**********************
MOVLW30H;基本指令操作
CALLSEND_I
MOVLW01H;清除顯示
CALLSEND_I
MOVLW06H;指定在寫入或讀取時,光標的移動方向
CALLSEND_I
MOVLW0CH;開顯示,關光標,不閃爍
CALLSEND_I
;***********************顯示漢字************************
HAN_WR2
CALLCLEAR_P;清屏
HAN_WR2A;“深圳乾龍盛電子”
CALLQUSHU
GOTO$
;************************寫準備****************************
WR_ZB
MOVLW34H
CALLSEND_I
MOVFWLCD_Y;Y地址
CALLSEND_I
MOVFWLCD_X;頁地址
CALLSEND_I
MOVLW30H
CALLSEND_I
RETURN
;***********************清屏*******************************
CLEAR_P
MOVLW1H;清除顯示
CALLSEND_I
RETURN
;***********************取數(shù)顯示程序***********************
QUSHU
CLRFPOINT;取數(shù)地址低8位
CLRFPOINT+1;取數(shù)地址高8位(因為一共需要(128/8)*64個數(shù)據(jù))
CLRFPOINT2;POINT的臨時寄存器
CLRFPOINT3;POINT+1的臨時寄存器
MOVLW02H;整塊屏分為上下兩個小屏(每小屏共32行)
MOVWFCOUNT3
MOVLW80H;上半屏的起始地址
MOVWFLCD_X
QUSHU1
MOVLW80H;每一行的第一個字節(jié)的地址
MOVWFLCD_Y
MOVLW20H;每一小屏共32行
MOVWFCOUNT2
QUSHU2
MOVLW10H;每一行共16個字節(jié)(16*8=128)
MOVWFCOUNT1
CALLWR_ZB;調(diào)用寫準備函數(shù)
QUSHU3
CALLTAB1;查表
CALLSEND_D;寫入到LCD的GDROM里
CLRFPOINT3
INCFPOINT,1;偏移地址加1,查找下一個數(shù)據(jù)
BTFSCSTATUS,Z;低8位是否有溢出
INCFPOINT+1,1;有,高8位+1
DECFSZCOUNT1,1;是否寫完一行16個字節(jié)
GOTOQUSHU3;否,返回去繼續(xù)寫
INCFLCD_Y,1;是,寫下一行
DECFSZCOUNT2,1;是否寫完32行
GOTOQUSHU2;否,繼續(xù)寫
MOVLW88H;是,寫下半屏
MOVWFLCD_X
DECFSZCOUNT3,1;是否寫完下半屏
GOTOQUSHU1;否,繼續(xù)寫
;是,開顯示
MOVLW36H;擴展指令,圖形顯示開
CALLSEND_I
MOVLW30H;基本指令
CALLSEND_I
RETURN
;************************送數(shù)據(jù)到LCD***********************
;寫數(shù)據(jù)子程序
;RS=1,RW=0,E=高脈沖,D0-D7=數(shù)據(jù)
;**********************************************************
SEND_D
MOVWFTEMP1;暫存數(shù)據(jù)
CALLCHK_BUSY;判斷總線是否忙
BSFRS
BCFRW
MOVFWTEMP1
MOVWFPORTD;送出數(shù)據(jù)
BSFE
NOP
NOP
BCFE
RETURN
;************************送命令到LCD***********************
;寫指令子程序
;RS=0,RW=0,E=高脈沖,D0-D7=指令碼
;**********************************************************
SEND_I
MOVWFTEMP1;暫存命令
CALLCHK_BUSY;判斷總線是否忙
BCFRS
BCFRW
MOVFWTEMP1
MOVWFPORTD;送命令
BSFE
NOP
NOP
BCFE
RETURN
;************************判斷總線是否忙********************
;測忙碌子程序
;RS=0,RW=1,E=H,D0-D7=狀態(tài)字
;**********************************************************
CHK_BUSY
BANKSELTRISD
MOVLW0FFH
MOVWFTRISD;D口設置為輸入
CLRFSTATUS
MOVLW0FFH
MOVWFPORTD
BCFRS
BSFRW
CHECK_BUSY_1
NOP
NOP
NOP
BSFE
NOP
NOP
NOP
BTFSSPORTD,7;D7為高表示總線忙,為低表示總線空閑
GOTO$+6
NOP
NOP
NOP
BCFE
GOTOCHECK_BUSY_1
BCFE
BANKSELTRISD
CLRFTRISD;恢復D口為輸出
CLRFSTATUS
RETURN
;***************************延時程序***************************
DELAY
MOVLW0afH
MOVWF20H
MOVLW0ffh
MOVWF21H
DECFSZ21H,1
GOTO$-1
DECFSZ20H,1
GOTO$-5
RETURN
;***************************延時程序1**************************
;顯示閃爍用
DELAY1
MOVLW05H
MOVWF22H
CALLDELAY
DECFSZ22H,1
GOTO$-2
RETURN
;***************************數(shù)據(jù)表格**************************
TAB1
MOVLWLOW(TAB1A);獲取數(shù)據(jù)表頭的低8位地址
ADDWFPOINT,0;并上取數(shù)的低8位
MOVWFPOINT2;轉存到POINT2里
BTFSCSTATUS,C;判斷低8位是否有溢出
INCFPOINT3,1;是,高8位+1
MOVLWHIGH(TAB1A);獲取數(shù)據(jù)表頭的高8位地址
ADDWFPOINT3,0
ADDWFPOINT+1,0;并上取數(shù)的高8位
MOVWFPCLATH;準備PC的高5位
MOVFWPOINT2
MOVWFPCL;準備PC的低8位
TAB1A:;數(shù)據(jù)表
DT0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X00
DT0X18,0XFC,0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00,0X3F,0X8E,0XE0,0X00,0X00
DT0X1E,0X03,0X00,0X1F,0X78,0X00,0X00,0X07,0XC7,0XFC,0X00,0X0F,0X7F,0XA0,0X00,0X00
DT0X1F,0X80,0X00,0X1B,0XF0,0X00,0X00,0X09,0XCF,0XFC,0X00,0X00,0X0F,0XE0,0X0F,0X00
DT0X1F,0XFE,0X00,0X19,0XF0,0X00,0X00,0X07,0XC9,0XFE,0X00,0X07,0X1F,0XE0,0X06,0X00
DT0X1F,0XFF,0XC0,0X0F,0XE0,0X00,0X00,0X03,0XC1,0XFE,0X00,0XFF,0XFF,0XE0,0X06,0X00
DT0X1F,0XC0,0X40,0X0F,0XC0,0X00,0X00,0X03,0XE7,0XFE,0X00,0X9F,0XFF,0X20,0X06,0X00
DT0X1F,0X00,0X00,0X0F,0XC0,0X00,0X00,0X07,0XE7,0XFC,0X00,0X0B,0XCF,0X20,0X06,0X00
DT0X1F,0X78,0X00,0X0F,0XC0,0X00,0X00,0X07,0XE7,0XFC,0X00,0X00,0X0F,0XE0,0X06,0X00
DT0X1F,0XFF,0X80,0X07,0XF0,0X00,0X00,0X03,0XEF,0XFC,0X00,0X00,0X3F,0XE0,0X06,0X00
DT0X13,0XFF,0XE0,0X07,0XFE,0X01,0XE0,0X01,0XCF,0XFC,0X00,0X00,0X3F,0XE0,0X06,0X60
DT0X1F,0XFC,0X00,0X07,0XE3,0X03,0XF8,0X06,0XDF,0XFC,0X00,0X1F,0XFE,0X60,0X06,0X60
DT0X1F,0X80,0X00,0X03,0X80,0X80,0XC0,0X01,0XFF,0XF8,0X00,0X0F,0X3F,0XE0,0X0F,0XE0
DT0X1C,0X00,0X00,0X01,0X80,0X41,0XC0,0X06,0XFF,0XF8,0X00,0X00,0XF3,0XE0,0X00,0X00
DT0X13,0XFC,0X00,0X03,0XFC,0X41,0XFC,0X03,0X7F,0XF0,0X00,0X00,0X0F,0XE0,0X00,0X00
DT0X1F,0XFF,0X00,0X03,0XFE,0X40,0XFF,0X00,0XFF,0XF0,0X00,0X07,0XFF,0XE0,0X07,0XC0
DT0X1F,0XC0,0X00,0X02,0XF0,0X40,0XE1,0X00,0X78,0XF0,0X00,0X3C,0XFC,0X20,0X0C,0X60
DT0X1E,0X00,0X00,0X02,0XC0,0XC0,0X60,0X00,0XF3,0X70,0X00,0X03,0XFF,0XE0,0X00,0X60
DT0X10,0X00,0X00,0X02,0X00,0X80,0X60,0X00,0X67,0X30,0X00,0X00,0X7F,0XE0,0X00,0XC0
DT0X17,0XFF,0X00,0X03,0X01,0X80,0X30,0X00,0XFC,0XB0,0X00,0X3F,0XCF,0XE0,0X01,0X80
DT0X1F,0XFA,0X00,0X03,0X03,0X80,0X18,0X01,0XFC,0X70,0X00,0X3C,0X8F,0XE0,0X03,0X00
DT0X1F,0XB0,0X00,0X03,0X0F,0X00,0X0C,0X02,0XFE,0X30,0X00,0X0D,0X3F,0X60,0X06,0X00
DT0X1F,0X00,0X00,0X03,0X0F,0X00,0X04,0X05,0XEE,0X30,0X00,0X03,0XDF,0X20,0X0C,0X00
DT0X1C,0X00,0X00,0X02,0X01,0X06,0X00,0X07,0XE3,0X30,0X01,0X00,0XDF,0XE0,0X0C,0X60
DT0X10,0X1E,0X00,0X03,0X03,0X03,0X80,0X07,0XF1,0X30,0X00,0XE0,0X33,0XE0,0X0F,0XE0
DT0X1F,0XEC,0X00,0X02,0X03,0X01,0XE0,0X09,0XF0,0X60,0X00,0X3C,0X8E,0X60,0X00,0X00
DT0X1F,0X30,0X00,0X03,0X03,0X9D,0X30,0X13,0XFC,0X60,0X00,0X1F,0X3F,0XA0,0X00,0X00
DT0X1F,0XC1,0X8C,0X02,0X81,0XF3,0X10,0X0F,0XF0,0XC0,0X03,0X87,0XC7,0XE0,0X03,0X80
DT0X1A,0X06,0X30,0X03,0X03,0X80,0X08,0X13,0XE0,0XC0,0X00,0XE3,0XF1,0XE0,0X06,0XC0
DT0X1C,0X1C,0X40,0X01,0X82,0X00,0X04,0X0F,0XE1,0X80,0X00,0X78,0XFE,0X60,0X0C,0X60
DT0X13,0XF8,0X80,0X01,0X46,0X00,0X00,0X07,0XE3,0X00,0X00,0X3E,0X7F,0XE0,0X0C,0X60
DT0X1F,0X63,0X00,0X01,0X8C,0X00,0X00,0X07,0XFE,0X00,0X00,0X0F,0X9F,0XE0,0X0D,0X60
DT0X1F,0X8E,0X04,0X01,0X47,0XEE,0X00,0X07,0XFE,0X00,0X00,0X87,0XEF,0XE0,0X0D,0X60
DT0X1E,0X3C,0X1C,0X00,0XA7,0XFF,0X8C,0X03,0XF8,0X00,0X00,0XC1,0XFF,0XE0,0X0C,0X60
DT0X1F,0X78,0X38,0X00,0XC3,0X93,0X8E,0X07,0XF0,0X00,0X00,0X78,0X7F,0XE0,0X0C,0X60
DT0X1F,0XF1,0X60,0X00,0XE3,0X80,0X06,0X07,0XF0,0X00,0X00,0X3A,0X1F,0XE0,0X06,0XC0
DT0X1F,0XE1,0X40,0X00,0X13,0XC8,0X00,0X0B,0XF0,0X00,0X00,0X1E,0X13,0XE0,0X03,0X80
DT0X17,0X8F,0X84,0X00,0X61,0XF8,0X00,0X17,0XF0,0X00,0X00,0X0F,0XB0,0XE0,0X00,0X00
DT0X1F,0X1E,0X29,0X80,0X33,0X00,0X00,0X0F,0XFC,0X00,0X00,0X43,0XFD,0X60,0X00,0X00
DT0X1E,0X7C,0X73,0X00,0X3A,0X10,0X00,0X0F,0XF4,0X00,0X00,0X21,0XFF,0XA0,0X03,0X80
DT0X15,0XF8,0XE3,0X00,0X1E,0X18,0X00,0X1F,0XF6,0X00,0X00,0X18,0XFF,0XE0,0X06,0XC0
DT0X1B,0XE1,0X86,0X00,0X1E,0X00,0X00,0X3F,0XE6,0X00,0X03,0X0E,0X7F,0XE0,0X0C,0X60
DT0X1F,0XC7,0X8C,0X00,0X1E,0X00,0X00,0X7F,0XE7,0X00,0X03,0X85,0X1B,0XE0,0X0C,0X60
DT0X1F,0X0F,0X39,0X20,0X07,0X00,0X01,0XFF,0XCF,0X00,0X01,0XC3,0XCD,0XE0,0X0D,0X60
DT0X1E,0X3E,0X73,0X40,0X03,0X80,0X0F,0XFF,0X9F,0X80,0X00,0XF1,0XF0,0X60,0X0D,0X60
DT0X18,0X7C,0XF6,0X20,0X01,0XE0,0X3F,0XFE,0X3F,0XE0,0X00,0X78,0XFE,0X60,0X0C,0X60
DT0X11,0XFB,0XE6,0X40,0X01,0XFF,0XFF,0XFC,0X7F,0XFC,0X08,0X3C,0X7F,0XE0,0X0C,0X60
DT0X1F,0XF7,0XFE,0X40,0X02,0XFF,0XFF,0XF9,0XFF,0XFF,0X00,0X0F,0X3F,0XE0,0X06,0XC0
DT0X1F,0XFF,0XFC,0X88,0X06,0XFF,0XFD,0XF3,0XFF,0XFF,0XC1,0X8F,0X9F,0XE0,0X03,0X80
DT0X1F,0XFF,0XB9,0X38,0X0E,0XFE,0X71,0XE7,0XFF,0XFF,0XE8,0XC3,0XEF,0XE0,0X00,0X00
DT0X0F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X00
;***************************源程序結束************************
end