• <li id="00i08"><input id="00i08"></input></li>
  • <sup id="00i08"><tbody id="00i08"></tbody></sup>
    <abbr id="00i08"></abbr>
  • 新聞中心

    HD44780讀寫(xiě)C51程序

    作者: 時(shí)間:2013-01-07 來(lái)源:網(wǎng)絡(luò) 收藏

    下面我給大家介紹一個(gè)讀寫(xiě)c51程序

    #include reg51.h>
    #include intrins.h>

    sbit GND_LCD=P1^7;
    sbit rs=P1^0;
    sbit rw=P1^1;
    sbit e=P1^2;

    unsigned char busy(void);
    void ctrl(unsigned char);
    void wd_h(unsigned char);
    void wd_l(unsigned char);
    unsigned char rd(void);
    void write(unsigned char);
    void init(void);
    void NOP(void);

    void disp(unsigned char);


    unsigned int time;

    void int_t0 (void) interrupt 1 {
    TL0=TL0+30;TH0=0xfb;
    time++;
    }

    void wait(unsigned int w){
    time=0;
    while (timew) {}
    }


    void init(void) {
    unsigned char i;
    P1=0;
    for (i=0;i2;i++) {
    wd_l(0x30);
    wait(5);
    }
    wd_h(0x20);
    ctrl(0x28);
    ctrl(0x8);
    ctrl(3);
    ctrl(6);
    disp(0);
    ctrl(1);
    ctrl(8);
    ctrl(0xe);
    ctrl(0x80);
    }


    unsigned char busy(void){
    P1=0;
    return(rd());
    }

    unsigned char rd(void) {
    unsigned char dat0,dat1;
    rw=1;
    rs=0;
    P1=P1|0x78;
    e=1;
    dat0=P1;
    e=0;
    e=1;
    dat1=P1;
    P1=0;
    return(((dat01)0xf0) | ((dat1>>3)0xf) );
    }

    void ctrl(unsigned char dat){
    while (busy()>0x7f) {};
    rw=rs=0;
    wd_h(dat);
    wd_l(dat);
    }
    void wd_h(unsigned char dat){
    e=1;
    P1=P1|((dat0xf0)>>1);
    e=0;
    P1=P10x87;
    }
    void wd_l(unsigned char dat){
    e=1;
    P1=P1|((dat0xf)3);
    e=0;
    P1=0;
    }
    void write(unsigned char dat) {
    while (busy()>0x7f) {};
    rw=0;
    rs=1;
    wd_h(dat);
    wd_l(dat);
    }

    //===============讀寫(xiě)程序====================================
    void disp(unsigned char i) {
    unsigned char j;
    ctrl(1);
    ctrl(0x80);
    for (j=0;j6;j++) write(d[i][j]);
    write(' ');



    關(guān)鍵詞: HD44780 C51 單片機(jī)

    評(píng)論


    相關(guān)推薦

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

    關(guān)閉
    主站蜘蛛池模板: 自贡市| 安平县| 和平县| 邮箱| 盱眙县| 辽宁省| 济宁市| 南昌市| 阳朔县| 北海市| 麦盖提县| 巩留县| 长寿区| 江油市| 尚义县| 武定县| 曲周县| 清涧县| 广宗县| 衡阳市| 会宁县| 洛南县| 敦煌市| 琼中| 虹口区| 伊春市| 郎溪县| 嵊州市| 明水县| 琼中| 余庆县| 遂川县| 大连市| 汉寿县| 灵丘县| 樟树市| 玉树县| 广灵县| 陆良县| 开江县| 建瓯市|