<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 利用STC89C52單片機(jī)控制LCD1602(不帶中文字庫(kù))顯示的中文

          利用STC89C52單片機(jī)控制LCD1602(不帶中文字庫(kù))顯示的中文

          作者: 時(shí)間:2016-11-13 來(lái)源:網(wǎng)絡(luò) 收藏
          一、設(shè)計(jì)原理

          使用STC89C52單片機(jī)控制1602LCD(不帶中文字庫(kù)的);利用1602LCD(不帶中文字庫(kù)的)中的存儲(chǔ)器(64個(gè)字節(jié)00H-3FH)自建立8個(gè)5×8點(diǎn)陣的字符從而顯示中文字符。

          本文引用地址:http://www.ex-cimer.com/article/201611/316492.htm

          二、LCD1602的指令集:

          1、清屏

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          00

          00000001

          運(yùn)行時(shí)間(250Khz):1.64ms;

          功能:清DDRAM和AC值。

          2、歸位

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          00

          0000001*

          運(yùn)行時(shí)間(250Khz):1.64ms;

          功能:AC=0,光標(biāo)、畫(huà)面回HOME位。

          3、輸入方式設(shè)置

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          00

          000001I/DS

          運(yùn)行時(shí)間(250Khz):40us;

          功能:設(shè)置光標(biāo)、畫(huà)面移動(dòng)方式。

          其中:I/D=1:數(shù)據(jù)讀、寫(xiě)操作后,AC自動(dòng)增一;

          I/D=0:數(shù)據(jù)讀、寫(xiě)操作后,AC自動(dòng)減一;

          S=1:數(shù)據(jù)讀、寫(xiě)操作,畫(huà)面平移;

          S=0:數(shù)據(jù)讀、寫(xiě)操作,畫(huà)面不動(dòng);

          4、顯示開(kāi)關(guān)控制

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          00

          00001DCB

          運(yùn)行時(shí)間(250Khz):40us;

          功能:設(shè)置顯示、光標(biāo)及閃爍開(kāi)、關(guān)。

          其中:D表示顯示開(kāi)關(guān):D=1為開(kāi),D=0為關(guān);

          C表示光標(biāo)開(kāi)關(guān):C=1為開(kāi),C=0為關(guān);

          B表示閃爍開(kāi)關(guān):B=1為開(kāi),B=0為關(guān)。

          5、光標(biāo)、畫(huà)面位移

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          00

          0001S/CR/L**

          運(yùn)行時(shí)間(250Khz):40us;

          功能:光標(biāo)、畫(huà)面移動(dòng),不影響DDRAM。

          其中:S/C=1:畫(huà)面平移一個(gè)字符位;

          S/C=0:光標(biāo)平移一個(gè)字符位;

          R/L=1:右移;R/L=0:左移。

          6、功能設(shè)置

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          00

          001DLNF**

          運(yùn)行時(shí)間(250Khz):40us;

          功能:工作方式設(shè)置(初始化指令)。

          其中:DL=1,8位數(shù)據(jù)接口;DL=0,四位數(shù)據(jù)接口;

          N=1,兩行顯示;N=0,一行顯示;

          F=1,5´10點(diǎn)陣字符;F=0,5´7點(diǎn)陣字符。

          7、CGRAM地址設(shè)置

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          00

          01A5A4A3A2A1A0

          運(yùn)行時(shí)間(250Khz):40us;

          功能:設(shè)置CGRAM地址。A5~A0=0~3FH。

          8、DDRAM地址設(shè)置

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          00

          1A6A5A4A3A2A1A0

          運(yùn)行時(shí)間(250Khz):40us;

          功能:設(shè)置DDRAM地址。

          N=0,一行顯示A6~A0=0~4FH;

          N=1,兩行顯示,首行A6~A0=00H~2FH,

          次行A6~A0=40H~67H。

          9、讀BF及AC值

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          01

          BFAC6AC5AC4AC3AC2AC1AC0

          功能:讀忙BF值和地址計(jì)數(shù)器AC值。

          其中:BF=1:忙;BF=0:準(zhǔn)備好。

          此時(shí),AC值意義為最近一次地址設(shè)置(CGRAM或DDRAM)定義。

          10、寫(xiě)數(shù)據(jù)

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          10

          數(shù)據(jù)

          運(yùn)行時(shí)間(250Khz):40us;

          功能:根據(jù)最近設(shè)置的地址性質(zhì),數(shù)據(jù)寫(xiě)入DDRAM或CGRAM內(nèi)。

          11、讀數(shù)據(jù)

          RSR/W

          DB7DB6DB5DB4DB3DB2DB1DB0

          11

          數(shù)據(jù)

          運(yùn)行時(shí)間(250Khz):40us;

          功能:根據(jù)最近設(shè)置的地址性質(zhì),從DDRRAM或CGRAM數(shù)據(jù)讀出。

          三、程序:

          //液晶顯示中文-版本0.0

          //作者:pcdian

          //定義液晶的一些功能位

          //RS 為數(shù)據(jù)、指令寄存器選擇位

          //RW 為讀寫(xiě)選擇位

          //E 為使能位

          RS BIT p2.5

          RW BIT P2.6

          E BIT P2.7

          ORG 0000H

          SJMP START

          ORG 000BH

          LJMP Timer_IT

          ORG 0030H

          START:MOV SP,#60H

          MOV TMOD,#01H

          MOV TH0,#0A6H

          MOV TL0,#00H

          SETB EA

          SETB ET0

          CLR TR0

          MAIN:MOV P0,#01H //清屏

          ACALL ENABLE

          MOV P0,#38H //顯示模式設(shè)置為16字*2行

          ACALL ENABLE

          MOV P0,#0CH //不顯示光標(biāo)

          ACALL ENABLE

          MOV P0,#06H //顯示方向正向且屏不移動(dòng)

          ACALL ENABLE

          DISPLAY:ACALL DISPLAY_C0

          //我

          MOV P0,#80H

          ACALL ENABLE

          MOV P0,#00H

          ACALL WRITE

          MOV P0,#81H

          ACALL ENABLE

          MOV P0,#01H

          ACALL WRITE

          MOV P0,#82H

          ACALL ENABLE

          MOV P0,#02H

          ACALL WRITE

          MOV P0,#0C0H

          ACALL ENABLE

          MOV P0,#03H

          ACALL WRITE

          MOV P0,#0C1H

          ACALL ENABLE

          MOV P0,#04H

          ACALL WRITE

          MOV P0,#0C2H

          ACALL ENABLE

          MOV P0,#05H

          ACALL WRITE

          LCALL DELAY1S

          MOV P0,#01H

          ACALL ENABLE

          ACALL DISPLAY_C1

          //們

          MOV P0,#83H

          ACALL ENABLE

          MOV P0,#00H

          ACALL WRITE

          MOV P0,#84H

          ACALL ENABLE

          MOV P0,#01H

          ACALL WRITE

          MOV P0,#85H

          ACALL ENABLE

          MOV P0,#02H

          ACALL WRITE

          MOV P0,#0C3H

          ACALL ENABLE

          MOV P0,#03H

          ACALL WRITE

          MOV P0,#0C4H

          ACALL ENABLE

          MOV P0,#04H

          ACALL WRITE

          MOV P0,#0C5H

          ACALL ENABLE

          MOV P0,#05H

          ACALL WRITE

          LCALL DELAY1S

          MOV P0,#01H

          ACALL ENABLE

          ACALL DISPLAY_C2

          //的

          MOV P0,#86H

          ACALL ENABLE

          MOV P0,#00H

          ACALL WRITE

          MOV P0,#87H

          ACALL ENABLE

          MOV P0,#01H

          ACALL WRITE

          MOV P0,#88H

          ACALL ENABLE

          MOV P0,#02H

          ACALL WRITE

          MOV P0,#0C6H

          ACALL ENABLE

          MOV P0,#03H

          ACALL WRITE

          MOV P0,#0C7H

          ACALL ENABLE

          MOV P0,#04H

          ACALL WRITE

          MOV P0,#0C8H

          ACALL ENABLE

          MOV P0,#05H

          ACALL WRITE

          LCALL DELAY1S

          MOV P0,#01H

          ACALL ENABLE

          ACALL DISPLAY_C3

          //0

          MOV P0,#89H

          ACALL ENABLE

          MOV P0,#00H

          ACALL WRITE

          MOV P0,#8AH

          ACALL ENABLE

          MOV P0,#01H

          ACALL WRITE

          MOV P0,#0C9H

          ACALL ENABLE

          MOV P0,#02H

          ACALL WRITE

          MOV P0,#0CAH

          ACALL ENABLE

          MOV P0,#03H

          ACALL WRITE

          LCALL DELAY1S

          MOV P0,#01H

          ACALL ENABLE

          ACALL DISPLAY_C4

          //7

          MOV P0,#8BH

          ACALL ENABLE

          MOV P0,#00H

          ACALL WRITE

          MOV P0,#8CH

          ACALL ENABLE

          MOV P0,#01H

          ACALL WRITE

          MOV P0,#0CBH

          ACALL ENABLE

          MOV P0,#02H

          ACALL WRITE

          MOV P0,#0CCH

          ACALL ENABLE

          MOV P0,#03H

          ACALL WRITE

          //3

          MOV P0,#8DH

          ACALL ENABLE

          MOV P0,#04H

          ACALL WRITE

          MOV P0,#8EH

          ACALL ENABLE

          MOV P0,#05H

          ACALL WRITE

          MOV P0,#0CDH

          ACALL ENABLE

          MOV P0,#06H

          ACALL WRITE

          MOV P0,#0CEH

          ACALL ENABLE

          MOV P0,#07H

          ACALL WRITE

          LCALL DELAY1S

          MOV P0,#01H

          ACALL ENABLE

          LJMP DISPLAY

          DISPLAY_C0:MOV DPTR,#TAB0

          MOV R2,#48

          ACALL DISPLAY_C

          RET

          DISPLAY_C1:MOV DPTR,#TAB1

          MOV R2,#48

          ACALL DISPLAY_C

          RET

          DISPLAY_C2:MOV DPTR,#TAB2

          MOV R2,#48

          ACALL DISPLAY_C

          RET

          DISPLAY_C3:MOV DPTR,#TAB3

          MOV R2,#32

          ACALL DISPLAY_C

          RET

          DISPLAY_C4:MOV DPTR,#TAB4

          MOV R2,#64

          ACALL DISPLAY_C

          RET

          DISPLAY_C:MOV P0,#40H

          ACALL ENABLE

          MOV R3,#0

          DISPLAY_CC:MOV A,R3

          MOVC A,@A+DPTR

          MOV P0,A

          LCALL WRITE

          INC R3

          DJNZ R2,DISPLAY_CC

          RET

          ENABLE:

          CLR RS

          CLR RW

          CLR E

          ACALL DELAY

          SETB E

          RET

          WRITE:

          SETB RS

          CLR RW

          CLR E

          ACALL DELAY

          SETB E

          RET

          DELAY1S:SETB TR0

          CJNE R0,#20,DELAY1S

          CLR TR0

          MOV R0,#0

          RET

          DELAY:MOV R5,#08H

          L1:MOV R4,#0FAH

          L0:DJNZ R4,L0

          DJNZ R5,L1

          RET

          Timer_IT:MOV TH0,#0A6H

          MOV TL0,#00H

          INC R0

          RETI

          TAB0: //我

          DB 0x00,0x07,0x01,0x01,0x01,0x1F,0x01,0x01

          DB 0x19,0x01,0x01,0x01,0x01,0x1F,0x01,0x01

          DB 0x00,0x08,0x04,0x04,0x00,0x1F,0x00,0x04

          DB 0x01,0x07,0x19,0x01,0x01,0x01,0x05,0x02

          DB 0x18,0x00,0x00,0x01,0x06,0x00,0x00,0x00

          DB 0x14,0x18,0x10,0x08,0x09,0x05,0x03,0x01

          TAB1: //們

          DB 0x01,0x01,0x02,0x02,0x06,0x04,0x0c,0x14

          DB 0x08,0x04,0x06,0x04,0x10,0x10,0x10,0x10

          DB 0x00,0x00,0x1e,0x02,0x02,0x02,0x02,0x02

          DB 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00

          DB 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x00

          DB 0x02,0x02,0x02,0x02,0x02,0x0a,0x04,0x00

          TAB2: //的

          DB 0x02,0x02,0x04,0x0f,0x08,0x08,0x08,0x0f

          DB 0x02,0x02,0x02,0x13,0x14,0x14,0x18,0x12

          DB 0x00,0x00,0x00,0x1e,0x02,0x02,0x02,0x02

          DB 0x08,0x08,0x08,0x08,0x0f,0x08,0x08,0x00

          DB 0x11,0x11,0x10,0x10,0x10,0x10,0x00,0x00

          DB 0x02,0x12,0x12,0x02,0x02,0x14,0x08,0x00

          TAB3: //0

          DB 0x00,0x00,0x03,0x04,0x08,0x08,0x08,0x08

          DB 0x00,0x00,0x18,0x04,0x02,0x02,0x02,0X02

          DB 0x08,0x08,0x08,0x08,0x04,0x03,0x00,0x00

          DB 0x02,0x02,0x02,0x02,0x04,0x18,0x00,0x00

          TAB4: //7

          DB 0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x00

          DB 0x00,0x00,0x1E,0x1E,0x06,0x06,0x06,0X06

          DB 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00

          DB 0x06,0x06,0x06,0x06,0x06,0x06,0x00,0x00

          //3

          DB 0x00,0x00,0x0F,0x0F,0x00,0x00,0x00,0x0F

          DB 0x00,0x00,0x1E,0x1E,0x06,0x06,0x06,0X1E

          DB 0x0F,0x00,0x00,0x00,0x0F,0x0F,0x00,0x00

          DB 0x1E,0x06,0x06,0x06,0x1E,0x1E,0x00,0x00

          END

          四、總結(jié):

          雖然LCD1602可以利用自建字符顯示中文,但最多不能超過(guò)8個(gè)字符位。所以實(shí)際應(yīng)用中,無(wú)法同時(shí)顯示“我們的073”。該段程序沒(méi)來(lái)得及優(yōu)化,沒(méi)有充分利用單片機(jī)做重復(fù)的事情的優(yōu)點(diǎn);并且使代碼量增大,可讀較差(重復(fù)的,看起來(lái)頭暈);注釋少也致使可讀性差!



          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();