當前位置:首頁 > 單片機 > 單片機
[導讀] #include;__CONFIG_DEBUG_OFF&_CP_ALL&_WRT_HALF&_CPD_ON&_LVP_OFF&_BODEN_OFF&_PWRTE_ON&_WDT_OFF&_HS_OSC;芯片配置字,看門狗關,上電延時開,掉電檢測關,低壓編程關,加密,4M晶體HS振蕩#defineRSP

#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,0XB7,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0XFF,0XFF,0XE0,0X00,0X00

DT0X1E,0X7F,0X0C,0X00,0X00,0X07,0XFF,0XFF,0X80,0X00,0X0F,0XF8,0X7F,0XE0,0X03,0XC0
DT0X1F,0XE7,0X80,0X00,0X00,0X7F,0XFF,0XFF,0XC0,0X00,0X7F,0XE1,0XFF,0XE0,0X0C,0X60
DT0X1F,0X9B,0XE0,0X00,0X01,0XFF,0XFF,0XFF,0XF0,0X01,0X80,0X07,0XFF,0XE0,0X0C,0X60
DT0X1F,0XCF,0XE0,0X00,0X1F,0XFF,0XFF,0XFF,0XF8,0X01,0X00,0X1F,0XFF,0XE0,0X0C,0X60
DT0X13,0XE4,0XF0,0X00,0X7F,0XFF,0XFF,0XFF,0XFE,0X00,0X00,0XFF,0X0E,0X20,0X0C,0X60
DT0X10,0XF0,0XF0,0X00,0XFF,0XFE,0XFF,0XFF,0XFF,0X00,0X00,0XF8,0X0E,0X20,0X0C,0X60
DT0X1C,0X7C,0X38,0X01,0XEF,0XF4,0X0F,0XFF,0XFF,0X80,0X00,0X00,0X7F,0XE0,0X0C,0X60
DT0X1F,0X1E,0X08,0X03,0X9F,0XC0,0X00,0XFE,0XFF,0XC0,0X00,0X07,0XFF,0XE0,0X0D,0X60
DT0X1F,0X03,0X80,0X07,0X27,0X80,0X00,0X3F,0X3F,0XE0,0X00,0X7F,0XFF,0XE0,0X0D,0XE0
DT0X1E,0XE0,0XC0,0X06,0X4F,0X00,0X00,0X3F,0XBF,0XF0,0X00,0XFE,0X1C,0X20,0X07,0XC0
DT0X1F,0XF0,0X20,0X0E,0X4E,0X00,0X00,0X1F,0XCF,0XF8,0X00,0X00,0X7F,0XA0,0X00,0XC0
DT0X1F,0XFE,0X00,0X0C,0X9C,0X00,0X00,0X0F,0XFF,0XF8,0X00,0X00,0X7F,0XE0,0X00,0XE0

DT0X1F,0XFF,0X80,0X1D,0XF8,0X00,0X00,0X0F,0XF3,0XFC,0X00,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

本站聲明: 本文章由作者或相關機構授權發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或將催生出更大的獨角獸公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關鍵字: 阿維塔 塞力斯 華為

加利福尼亞州圣克拉拉縣2024年8月30日 /美通社/ -- 數(shù)字化轉型技術解決方案公司Trianz今天宣布,該公司與Amazon Web Services (AWS)簽訂了...

關鍵字: AWS AN BSP 數(shù)字化

倫敦2024年8月29日 /美通社/ -- 英國汽車技術公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開發(fā)耗時1.5...

關鍵字: 汽車 人工智能 智能驅動 BSP

北京2024年8月28日 /美通社/ -- 越來越多用戶希望企業(yè)業(yè)務能7×24不間斷運行,同時企業(yè)卻面臨越來越多業(yè)務中斷的風險,如企業(yè)系統(tǒng)復雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務連續(xù)性,提升韌性,成...

關鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報道,騰訊和網(wǎng)易近期正在縮減他們對日本游戲市場的投資。

關鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會開幕式在貴陽舉行,華為董事、質量流程IT總裁陶景文發(fā)表了演講。

關鍵字: 華為 12nm EDA 半導體

8月28日消息,在2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會上,華為常務董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語權最終是由生態(tài)的繁榮決定的。

關鍵字: 華為 12nm 手機 衛(wèi)星通信

要點: 有效應對環(huán)境變化,經(jīng)營業(yè)績穩(wěn)中有升 落實提質增效舉措,毛利潤率延續(xù)升勢 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務引領增長 以科技創(chuàng)新為引領,提升企業(yè)核心競爭力 堅持高質量發(fā)展策略,塑強核心競爭優(yōu)勢...

關鍵字: 通信 BSP 電信運營商 數(shù)字經(jīng)濟

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺與中國電影電視技術學會聯(lián)合牽頭組建的NVI技術創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會上宣布正式成立。 活動現(xiàn)場 NVI技術創(chuàng)新聯(lián)...

關鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會上,軟通動力信息技術(集團)股份有限公司(以下簡稱"軟通動力")與長三角投資(上海)有限...

關鍵字: BSP 信息技術
關閉
關閉