12864LCD问题

2019-03-24 20:06发布

//ACM-12864汉字液晶显示驱动程序


sbit p_csa=P2^6;
sbit p_csb=P2^7;
sbit p_gnda=P2^5;
sbit p_gndb=P2^4;
sbit p_di=P2^3;
sbit p_rw=P2^2;
sbit p_e=P2^1;


/*忙判别*/
void lcd_busy(void) {
        p_di=0;p_rw=1;P0=0xff;
        while (1) {
                p_e=1;
                if (P0<0x80) break;
                p_e=0;
        }
        p_e=0;
}
/*设置xy*/
void set_xy(unsigned char x,unsigned char y) {
        if (x>=64) {p_csa=0;p_csb=1;} else {p_csb=0;p_csa=1;}
        lcd_busy();
        p_di=p_rw=0;P0=0x40|x;p_e=1;p_e=0;
        lcd_busy();
        p_di=p_rw=0;P0=0xb8|y;p_e=1;p_e=0;
        P0=0xff;
}
void lw(unsigned char x,unsigned char y,unsigned char dd) {
        set_xy(x,y);
        lcd_busy();p_di=1;p_rw=0;P0=dd;p_e=1;p_e=0;
        P0=0xff;
}
/*显示初始化*/
#pragma disable
void lcd_init(void) {
        unsigned char x,y;
        p_gnda=p_gndb=0;
        /*开显示*/
        p_e=p_di=p_rw=0;
        p_csa=p_csb=0;
        p_csa=1;P0=0x3f;p_e=1;p_e=0;p_csa=0;
        p_csb=1;P0=0x3f;p_e=1;p_e=0;p_csb=0;
        /*0行开始显示*/
        p_csa=1;lcd_busy();p_di=p_rw=0;P0=0xc0;p_e=1;p_e=0;p_csa=0;
        p_csb=1;lcd_busy();p_di=p_rw=0;P0=0xc0;p_e=1;p_e=0;p_csb=0;
        for (y=0;y<8;y++) {
                for (x=0;x<128;x++) lw(x,y,0);
        }
}


unsigned char code asc[]={
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x0,0x0,0x38,0xfc,0xfc,0x38,0x0,0x0,0x0,0x0,0x0,0xd,0xd,0x0,0x0,0x0,
0x0,0xe,0x1e,0x0,0x0,0x1e,0xe,0x0,0x0,0x0,0x0,0x0,0x0,0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x0,0x4,0x4,0xbc,0xf8,0x40,0x40,0x0,0x0,0x8,0x8,0xf,0x7,0x0,0x0,0x0,
0x8,0xc,0x4,0xc,0x8,0xc,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
0x80,0xc0,0x60,0x30,0x60,0xc0,0x80,0x0,0x7,0x7,0x4,0x4,0x4,0x7,0x7,0x0
};


unsigned char code hz[]={
/*解:        0*/
0x20,0x10,0xec,0x27,0xf4,0x2c,0xe4,0x40,
0x22,0x9e,0x2,0xd2,0x22,0x1f,0x2,0x0,
0x80,0x40,0x3f,0x9,0x3f,0x89,0xff,0x8,
0xa,0x9,0x9,0xff,0x9,0x9,0x8,0x0
};


//显示汉字,fb==1:反白显示
void dh(unsigned char x,unsigned char y,unsigned char n,unsigned char fb) {
        unsigned char i,dd;
        for (i=0;i<16;i++) {
                dd=hz[i+n*32];
                if (fb) if (n!=kongbai) dd=255-dd;
                lw(x*8+i,y,dd);
                dd=hz[i+n*32+16];
                if (fb) if (n!=kongbai) dd=255-dd;
                lw(x*8+i,y+1,dd);
        }
}

//显示字符,fb==1:反白显示
void da(unsigned char x,unsigned char y,unsigned char n,unsigned char fb) {
        unsigned char i,dd;
        n-=32;
        if (n>128) n=0;
        if (fb) dd=255; else dd=0;
        lw(x*8,y,dd);
        lw(x*8,y+1,dd);
        for (i=0;i<7;i++) {
                dd=asc[i+n*16];
                if (fb) dd=255-dd;
                lw(x*8+i+1,y,dd);
                dd=asc[i+n*16+8];
                if (fb) dd=255-dd;
                lw(x*8+i+1,y+1,dd);
        }
}


想问下大家sbit p_csa=P2^6;
sbit p_csb=P2^7;
sbit p_gnda=P2^5;
sbit p_gndb=P2^4;
sbit p_di=P2^3;
sbit p_rw=P2^2;
sbit p_e=P2^1;
各定义的LCD的什么引脚功能 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
8条回答
chenrenbo
2019-03-25 18:34

 信霖电子商贸(上海)有限公司宁波分公司——合泰单片机HT(holtek)浙江代理商

提供盛群HOLTEK/合泰的全系列IC产品,可提供给客户详细的产品资料,样品,提供客户需求的技术支持,欢迎广大客户来电咨询.,技术实力强,可小家电产品设计开发,成熟方案,区域涉及浙江宁波、温州、杭州、金华、台州、绍兴等等地。

HT48R05AHT48R06A HT48R30AHT48R50A HT48R52AHT48R54AHT48F06EHT48F10EHT48F30EHT48R50EHT48F70EHT49R30AHT49R50AHT46R46HT46R47HT46R22HT46R23 HT46R62HT46R64HT56R62HT56R64 TK98P01    HT1621B/48SSOPHT1622HT1625HT1632CHT1626HT6220AHT6221AHT6222AHT49RA0HT49RA1HT45R22EHT45R35HT45R36HT45R37HT45R38 HT7612HT7610HT48R01CHT46R01CHT68F03HT66F03TE812P08STE622P08S HT48R063HT48R064HT48R065HT48R066HT48R0662HT48R067HT46R064HT46R065HT46R066HT46R0662HT46R067HT7133HT7533HT7150HT7130HT7550

陈任博(tony)信霖电子商贸(上海)有限公司宁波分公司 手机:15888568792  Q Q:  49324686  Add:宁波市海曙区段塘东路636号泛亚中心3号楼502

一周热门 更多>