131 1300 0010
其他
當(dāng)前位置: 首頁(yè)>> 元件技術(shù)>>其他>>
  • 導(dǎo)航欄目
  • 二極管
  • 整流橋
  • MOS管
  • 其他
  • MEGA8單片機(jī)對(duì)LCD1602液晶屏的驅(qū)動(dòng)
    MEGA8單片機(jī)對(duì)LCD1602液晶屏的驅(qū)動(dòng)
  • MEGA8單片機(jī)對(duì)LCD1602液晶屏的驅(qū)動(dòng)
  •   發(fā)布日期: 2019-04-09  瀏覽次數(shù): 1,261

    調(diào)試過(guò)程總結(jié)一下:

    1)由于找不到的1620資料,不知道它的操作時(shí)序??吹揭恍┨诱f(shuō)1620和1602沒(méi)區(qū)別,還是有點(diǎn)將信將疑。后面用網(wǎng)友編寫的1602程序試驗(yàn),才知道它們倆沒(méi)啥區(qū)別

     

    2)關(guān)于是否檢測(cè)LCD處于空閑,覺(jué)得還是最好在寫指令和寫數(shù)據(jù)時(shí)都加上。不檢測(cè),會(huì)導(dǎo)致顯示結(jié)果不正常。

    3)由于連線很多14根(加上背光就是16根),如果有一根除了問(wèn)題就會(huì)影響到顯示。所以我是用萬(wàn)用表一根線一根線量了之后才通電試驗(yàn)的。

    4)看到很多帖子都建議在初始化LCD前延時(shí)幾十毫秒。本例中并沒(méi)有延時(shí),顯示也正常。

    5)總的說(shuō)來(lái),不是很難。在遇到問(wèn)題時(shí)只要能夠仔細(xì)分析,就能找出原因和解決方法。自己前幾天在試程序時(shí)就是顯示結(jié)果不對(duì),一直在檢查自己的程序,沒(méi)想到原來(lái)是單片機(jī)的Flash到壽命了那個(gè)郁悶啊。

    MEGA8單片機(jī)對(duì)LCD1602液晶屏的驅(qū)動(dòng)

    頭文件中有五個(gè)函數(shù):

    Function1.unsigned char AskBusy(void) 詢問(wèn)LCD1620是否空閑, 返回值“1”空閑, “0”為忙;

    FuncTIon2.WritEDAta(char data) 寫數(shù)據(jù)到LCD1620;

    FuncTIon3.WriteCommand(char command) 寫指令到LCD1620;

    FuncTIon4.PutOneCharLCD(x,y,*Disp) 在LCD1620上顯示一個(gè)字符, x,y定義位置

    FuncTIon5.PutStringLCD(a,b,*DispString) 在LCD1620上顯示一個(gè)字符串, a,b定義初始位置。 Function6.LCD_Init() 初始化LCD

    在使用此頭文件之前,必須有以下宏定義:

    #define DataPortPullup PORTx

    #define DataPortDirection DDRx

    #define ReadLCDPINPINx

    #defineCTRlPortPullup PORTx

    #define CtrlPortDirection DDRx

    #define RS_Bit Px?

    #define RW_Bit Px?

    #define E_Bit Px?

    其中“x”代表B,C,D(mega8中無(wú)A口),“?”代表“0~1”

    完整頭文件如下(解釋搞了一大堆,也學(xué)學(xué)用英語(yǔ)……):

    /*******************************************************/

    /* Project :1620 Display Headfile */

    /* Date :2008,3,11 */

    /* Author :lhy */

    /* Version :v1.1 */

    /* Rework :lhy */

    /* Rework Date :2008.4.28 */

    /* */

    /* Comments : */

    /* 1 Function Description */

    /* Function1.unsigned char AskBusy(void) */

    /* --Calls this Fun to ask if LCD is busy, */

    /* 1--free,0--busy; */

    /* Function2.WritEDAta(char data) */

    /* --Write data to LCD */

    /* Function3.WriteCommand(char command) */

    /* --write command to LCD */

    /* Function4.PutOneCharLCD(x,y,*Disp) */

    /* --Put one char to LCD. */

    /* Function5.PutStringLCD(a,b,*DispString) */

    /* --Put String to LCD. Max length 32bits. */

    /* */

    /* 2 How to use */

    /* Before use this HeadFile, */

    /* need to define as below: */

    /* #define DataPortPullup PORTx */

    /* #define DataPortDirection DDRx */

    /* #define ReadLCDPin PINx */

    /* #define CtrlPortPullup PORTx */

    /* #define CtrlPortDirection DDRx */

    /* #define RS_Bit Px? */

    /* #define RW_Bit Px? */

    /* #define E_Bit Px? */

    /* ‘x’ -》 A,B,C,D.。. */

    /* ‘?’ -》 0,1,2,3,4,5,6,7 */

    /* And set control port output,like this: */

    /* CtrlPortDirection |= */

    /* (1《/* 3 Add the Function “LCD_Init(void)” */

    /* Before this Fun, you must set control port */

    /* output. */


  • ·上一篇:
    ·下一篇:
  • 其他關(guān)聯(lián)資訊
    深圳市日月辰科技有限公司
    地址:深圳市寶安區(qū)松崗鎮(zhèn)潭頭第二工業(yè)城A區(qū)27棟3樓
    電話:0755-2955 6626
    傳真:0755-2978 1585
    手機(jī):131 1300 0010
    郵箱:hu@szryc.com

    深圳市日月辰科技有限公司 版權(quán)所有:Copyright?2010-2023 www.kqne.cn 電話:13113000010 粵ICP備2021111333號(hào)