當(dāng)前位置:首頁(yè) > 單片機(jī) > 單片機(jī)
[導(dǎo)讀] #include;__CONFIG_DEBUG_OFF&_CP_ALL&_WRT_HALF&_CPD_ON&_LVP_OFF&_BODEN_OFF&_PWRTE_ON&_WDT_OFF&_HS_OSC;芯片配置字,看門(mén)狗關(guān),上電延時(shí)開(kāi),掉電檢測(cè)關(guān),低壓編程關(guān),加密,4M晶體HS振蕩#defineRSP

#include
;__CONFIG_DEBUG_OFF&_CP_ALL&_WRT_HALF&_CPD_ON&_LVP_OFF&_BODEN_OFF&_PWRTE_ON&_WDT_OFF&_HS_OSC
;芯片配置字,看門(mén)狗關(guān),上電延時(shí)開(kāi),掉電檢測(cè)關(guān),低壓編程關(guān),加密,4M晶體HS振蕩

#defineRSPORTA,5;命令/數(shù)據(jù)選擇
#DEFINERWPORTA,4;讀/寫(xiě)選擇
#DEFINEEPORTA,3;使能信號(hào)
#DEFINEPSBPORTA,2;并口/串口選擇(H/L)
#DEFINERSTPORTA,0;復(fù)位信號(hào)

;-----------------------------------------------
LCD_XEQU30H;頁(yè)地址
LCD_YEQU31H;Y地址
COUNTEQU32H;循環(huán)計(jì)數(shù)用
COUNT1EQU33H;循環(huán)計(jì)數(shù)用
COUNT2EQU34H;循環(huán)計(jì)數(shù)用
COUNT3EQU35H

POINTEQU36H;查表偏移地址
POINT1EQU37H;查表偏移地址
POINT2EQU38H;查表偏移地址
POINT3EQU40H
TEMPEQU39H;臨時(shí)寄存器
TEMP1EQU3AH;臨時(shí)寄存器
;-----------------------------------------------
ORG0000H;復(fù)位地址
NOP;ICD需要的空指令
GOTOMAIN;跳轉(zhuǎn)到主程序


;**********************主程序************************
MAIN
BANKSELTRISA
CLRFTRISA;A口輸出
CLRFTRISD;D口輸出
BANKSELADCON1
MOVLW06H
MOVWFADCON1;A口全為數(shù)字口
CLRFSTATUS

BCFRST;復(fù)位LCD
CALLDELAY;延時(shí)一段時(shí)間
BSFRST;清除復(fù)位信號(hào)
NOP
BSFPSB;并口通訊

;**************************初始化**********************
MOVLW30H;基本指令操作
CALLSEND_I
MOVLW01H;清除顯示
CALLSEND_I
MOVLW06H;指定在寫(xiě)入或讀取時(shí),光標(biāo)的移動(dòng)方向
CALLSEND_I
MOVLW0CH;開(kāi)顯示,關(guān)光標(biāo),不閃爍
CALLSEND_I
;***********************顯示漢字************************
HAN_WR2
CALLCLEAR_P;清屏
HAN_WR2A;“深圳乾龍盛電子”

CALLQUSHU
GOTO$
;************************寫(xiě)準(zhǔn)備****************************
WR_ZB
MOVLW34H
CALLSEND_I
MOVFWLCD_Y;Y地址
CALLSEND_I
MOVFWLCD_X;頁(yè)地址
CALLSEND_I
MOVLW30H
CALLSEND_I
RETURN

;***********************清屏*******************************
CLEAR_P
MOVLW1H;清除顯示
CALLSEND_I
RETURN
;***********************取數(shù)顯示程序***********************
QUSHU
CLRFPOINT;取數(shù)地址低8位
CLRFPOINT+1;取數(shù)地址高8位(因?yàn)橐还残枰?28/8)*64個(gè)數(shù)據(jù))
CLRFPOINT2;POINT的臨時(shí)寄存器
CLRFPOINT3;POINT+1的臨時(shí)寄存器

MOVLW02H;整塊屏分為上下兩個(gè)小屏(每小屏共32行)
MOVWFCOUNT3
MOVLW80H;上半屏的起始地址
MOVWFLCD_X
QUSHU1
MOVLW80H;每一行的第一個(gè)字節(jié)的地址
MOVWFLCD_Y
MOVLW20H;每一小屏共32行
MOVWFCOUNT2
QUSHU2
MOVLW10H;每一行共16個(gè)字節(jié)(16*8=128)
MOVWFCOUNT1
CALLWR_ZB;調(diào)用寫(xiě)準(zhǔn)備函數(shù)
QUSHU3
CALLTAB1;查表
CALLSEND_D;寫(xiě)入到LCD的GDROM里
CLRFPOINT3
INCFPOINT,1;偏移地址加1,查找下一個(gè)數(shù)據(jù)
BTFSCSTATUS,Z;低8位是否有溢出
INCFPOINT+1,1;有,高8位+1
DECFSZCOUNT1,1;是否寫(xiě)完一行16個(gè)字節(jié)
GOTOQUSHU3;否,返回去繼續(xù)寫(xiě)
INCFLCD_Y,1;是,寫(xiě)下一行
DECFSZCOUNT2,1;是否寫(xiě)完32行
GOTOQUSHU2;否,繼續(xù)寫(xiě)
MOVLW88H;是,寫(xiě)下半屏
MOVWFLCD_X
DECFSZCOUNT3,1;是否寫(xiě)完下半屏
GOTOQUSHU1;否,繼續(xù)寫(xiě)
;是,開(kāi)顯示
MOVLW36H;擴(kuò)展指令,圖形顯示開(kāi)
CALLSEND_I
MOVLW30H;基本指令
CALLSEND_I
RETURN

;************************送數(shù)據(jù)到LCD***********************
;寫(xiě)數(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***********************
;寫(xiě)指令子程序
;RS=0,RW=0,E=高脈沖,D0-D7=指令碼
;**********************************************************
SEND_I
MOVWFTEMP1;暫存命令
CALLCHK_BUSY;判斷總線是否忙
BCFRS
BCFRW
MOVFWTEMP1
MOVWFPORTD;送命令
BSFE
NOP
NOP
BCFE
RETURN
;************************判斷總線是否忙********************
;測(cè)忙碌子程序
;RS=0,RW=1,E=H,D0-D7=狀態(tài)字
;**********************************************************
CHK_BUSY
BANKSELTRISD
MOVLW0FFH
MOVWFTRISD;D口設(shè)置為輸入
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;恢復(fù)D口為輸出
CLRFSTATUS
RETURN
;***************************延時(shí)程序***************************
DELAY
MOVLW0afH
MOVWF20H
MOVLW0ffh
MOVWF21H
DECFSZ21H,1
GOTO$-1
DECFSZ20H,1
GOTO$-5
RETURN
;***************************延時(shí)程序1**************************
;顯示閃爍用
DELAY1
MOVLW05H
MOVWF22H
CALLDELAY
DECFSZ22H,1
GOTO$-2
RETURN

;***************************數(shù)據(jù)表格**************************
TAB1
MOVLWLOW(TAB1A);獲取數(shù)據(jù)表頭的低8位地址
ADDWFPOINT,0;并上取數(shù)的低8位
MOVWFPOINT2;轉(zhuǎn)存到POINT2里
BTFSCSTATUS,C;判斷低8位是否有溢出
INCFPOINT3,1;是,高8位+1
MOVLWHIGH(TAB1A);獲取數(shù)據(jù)表頭的高8位地址
ADDWFPOINT3,0
ADDWFPOINT+1,0;并上取數(shù)的高8位

MOVWFPCLATH;準(zhǔn)備PC的高5位
MOVFWPOINT2
MOVWFPCL;準(zhǔn)備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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00,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,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F,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X00
;***************************源程序結(jié)束************************
end

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

9月2日消息,不造車(chē)的華為或?qū)⒋呱龈蟮莫?dú)角獸公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

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

關(guān)鍵字: 汽車(chē) 人工智能 智能驅(qū)動(dòng) BSP

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

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

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

關(guān)鍵字: 騰訊 編碼器 CPU

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

關(guān)鍵字: 華為 12nm EDA 半導(dǎo)體

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

關(guān)鍵字: 華為 12nm 手機(jī) 衛(wèi)星通信

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

關(guān)鍵字: 通信 BSP 電信運(yùn)營(yíng)商 數(shù)字經(jīng)濟(jì)

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

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

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

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉