找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3980|回复: 3
打印 上一主题 下一主题
收起左侧

各位大神,谁有用51驱动128x64的LCD,驱动芯片是ST7567

[复制链接]
跳转到指定楼层
楼主
ID:127575 发表于 2016-6-21 17:09 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
各位大神帮帮忙,程序的时序没有问题,硬件方面参考手册,现在贴上c文件,


#include "reg51.h"
#include "absacc.h"
#define unchar  unsigned char
#define unint   unsigned int
//--------------------------------------------------------- 4线SPI接口 驱动
                                                                                                                                                  
sbit    RSTB        =P1^3;

sbit    SDI     =P1^0;
sbit        SCL                =P2^0;
sbit    CS0          =P1^4;
sbit    A0      =P1^2;

sbit    KEY            =P1^5;
//sbit    LED            =P2^0;
unchar code graphic1[]=
{

/*--  宽度x高度=128x64  --*/
0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x81,0xC1,0x41,0x41,0x41,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x81,0x01,0x01,0x81,0x81,0xC1,0x01,0x81,0xC1,0x81,0x81,0xC1,0xC1,0x01,
0x81,0x81,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,
0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0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x01,0x03,0x03,0x07,0x07,
0x05,0x05,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x81,0xC1,0x43,0xC7,0xC3,0x07,0x03,0x02,0x00,
0x00,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xEF,0xE7,0xF7,0xFF,0xFF,0xF7,
0xFB,0xFF,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xDF,0xCF,0xC7,0x85,0x86,0x87,
0x8F,0x8F,0x1D,0x19,0x3D,0x3C,0x3C,0x7C,0x7D,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFE,0xF7,0xFB,0xF8,0xFC,0xF8,0xF8,0xFC,0xFE,0xF8,0xFC,0xFE,0xFC,0xFF,0xFF,
0xFF,0xFF,0x7F,0x7F,0x3F,0x0F,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xE0,0xC0,0x67,0x7C,0x3F,0x3B,0x39,0x1C,0x1C,0x0E,0x0F,
0x0F,0x0F,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
0x1F,0x0F,0x0F,0x0F,0x07,0x07,0x03,0x03,0x03,0x03,0x03,0x01,0x21,0x71,0x59,0x9B,
0xEF,0x7F,0x3F,0x03,0x03,0x01,0x01,0x03,0x00,0x00,0x03,0x07,0x07,0x03,0x07,0x07,
0x0F,0x07,0x07,0x0F,0x07,0x0F,0x0F,0x0F,0x1F,0x9F,0x9F,0xDF,0xFB,0xFB,0x79,0x39,
0x19,0x18,0x08,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x80,0x80,0x80,0x80,
0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,
0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0xC0,0x80,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0xC0,0xC0,0x00,0x00,
0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00,
0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x80,0x80,0x00,0x01,0x01,0x00,
0x00,0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,
0x00,0xC0,0xC0,0x00,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0xFF,0x00,0x00,0x00,0x00,0x00,0x84,0xEC,0x79,0x93,0xD7,0x77,0xFF,0xFD,0x6B,0xCB,
0x89,0x80,0x80,0x00,0x00,0x40,0x48,0x7F,0x3F,0xA4,0xE4,0x7F,0x3F,0x7F,0x7F,0xFF,
0xFF,0x00,0x00,0x00,0x00,0x02,0x02,0x7A,0x7A,0xFE,0xFF,0x25,0x7D,0x7D,0x01,0x01,
0x00,0x00,0x00,0x48,0x69,0x39,0xFF,0xFF,0x14,0x24,0x25,0x35,0xFF,0xFF,0x10,0x10,
0x00,0x00,0x00,0x3E,0x3F,0x25,0x3F,0xBF,0xFF,0x7F,0x14,0x14,0xFF,0xFF,0x00,0x00,
0x00,0x08,0x2C,0xFF,0xFB,0xEA,0xC2,0xFD,0x7F,0xF3,0xFF,0x0E,0xC0,0xC0,0x00,0x00,
0x48,0x69,0x39,0xFF,0xFF,0x14,0x24,0x25,0x35,0xFF,0xFF,0x10,0x10,0x00,0x00,0x44,
0x64,0xFF,0xFF,0x0A,0x12,0xB2,0xFF,0xFF,0xB9,0x81,0x00,0x00,0x00,0x00,0x00,0xFF,
0xFF,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x81,0x81,0x80,0x80,0x83,0x83,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x81,0x81,0x80,0x80,0x80,0x80,0x80,0x83,
0x83,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x83,0x83,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x81,0x81,0x80,0x80,0x80,0x80,0x83,0x83,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x82,0x83,0x81,0x80,0x80,0x81,0x83,0x83,0x81,0x80,0x80,
0x80,0x80,0x80,0x81,0x81,0x81,0x81,0x80,0x80,0x80,0x81,0x81,0x81,0x81,0x80,0x80,
0x80,0x80,0x80,0x81,0x81,0x80,0x80,0x80,0x80,0x83,0x83,0x80,0x80,0x80,0x80,0x80,
0x81,0x83,0x83,0x81,0x81,0x81,0x80,0x80,0x81,0x81,0x81,0x81,0x80,0x80,0x80,0xFF,
};
void Init_ST7567();
void Write_ST7567_COM(unchar COMDADA_4SPI);
void Write_ST7567_DISPLAY_DATA_serial_4SPI(unchar DADA_4SPI);
void Delay_ms(unsigned long value);
void HDReset();
void Keypress(void);
void clear_screen(unchar xx);
void Display_pic1();


void main()
{
//      Write_ST7567_COM(0xe2);       
//        SCL=1;
        Init_ST7567();

        while(1)
        {
//         clear_screen(0x33);
//                 Keypress();         
//         clear_screen(0xff);
//                 Keypress();
//         clear_screen(0x55);
//                 Keypress();
//         clear_screen(0xaa);
//                 Keypress();
//         Display_pic1();
//         Keypress();
//          Write_ST7567_COM(0xa7);           // //0xa6正向显示,0xa7反向显示
         Display_pic1();
         Keypress();
         }

}

//--------------------------------------------------------------------------

void Init_ST7567()
{
        HDReset();
        Delay_ms(100);

       Write_ST7567_COM(0xe2);          //SOFT RESET//寄存器复位

       Write_ST7567_COM(0xaf);          //0xaf显示器开
       Write_ST7567_COM(0x2f);          //0x2f升压电路,电压管理电路,
                     
       Write_ST7567_COM(0x25);           //0x20-0x27为V5电压内部电阻调整设置

       Write_ST7567_COM(0x81);           // SET EV 调对比度
       Write_ST7567_COM(0x1F);           //0x01-0x3f电量寄存器设置模式

       Write_ST7567_COM(0xa0);           //0xa0为Segment正向,0xa1 为Segment反向
                     
       Write_ST7567_COM(0xc8);           //0xc0正向扫描,0xc8反射扫描

       Write_ST7567_COM(0xa6);           // //0xa6正向显示,0xa7反向显示
       Write_ST7567_COM(0xa4);           // //0xa4正常显示,0xa5全屏点亮

//      Write_ST7567_COM(0xac);           //
//      Write_ST7567_COM(0x00);       

       Write_ST7567_COM(0xf8);           // //背压比设置
       Write_ST7567_COM(0x00);                 //00--10
}


void clear_screen(unchar xx)
{
unchar i,j;
for(i=0;i<8;i++)
        {
                CS0=0;
                Write_ST7567_COM(0xb0+i);         //SET PAGE 0---8
            Write_ST7567_COM(0x10);         //SET COLUMN MSB
                Write_ST7567_COM(0x00);          //SET CLUMN LSB
                for(j=0;j<128;j++)
                {
                        Write_ST7567_DISPLAY_DATA_serial_4SPI(xx);
                }
         }
}

void Display_pic1()
{
        unint i,j,adressd=0;

        for(i=0;i<8;i++)
        {
                CS0=0;
                Write_ST7567_COM(0xb0+i);
            Write_ST7567_COM(0x10);
                Write_ST7567_COM(0x00);
                for(j=0;j<128;j++)
                {
                        Write_ST7567_DISPLAY_DATA_serial_4SPI(graphic1[adressd]);
                        adressd++;
                }
        }
}
//***************************************************************************SPI4
void Write_ST7567_COM(unchar COMDADA_4SPI)
{
        unchar bit8;
        A0=0;
        CS0=0;
        for(bit8=0;bit8<8;bit8++)
        {
                Delay_ms(10);
                SCL=0;
                Delay_ms(10);
                if((COMDADA_4SPI&0x80)==0x80)
                SDI=1;
                else               
                SDI=0;
                        Delay_ms(10);
                SCL=1;
                        Delay_ms(10);
                COMDADA_4SPI=(COMDADA_4SPI<<1);

        }
    CS0=1;
                       
}

void Write_ST7567_DISPLAY_DATA_serial_4SPI(unchar DADA_4SPI)
{   
        unchar bit8;
        A0=1;
        CS0=0;                               

        for(bit8=0;bit8<8;bit8++)
        {
        Delay_ms(10);
                SCL=0;
                Delay_ms(10);
                if((DADA_4SPI&0x80)==0x80)
                SDI=1;
                else
                SDI=0;
                Delay_ms(10);
                SCL=1;
                DADA_4SPI=(DADA_4SPI<<1);

        }
        CS0=1;
}

               
void Delay_ms(unsigned long value)
{
        unint i,j;
    for (i=0;i<value;i++)
                for (j=0;j<500;j++);
}

void HDReset()
{
        RSTB=0;
        Delay_ms(2);
        RSTB=1;
        Delay_ms(4);
}

void Keypress()
        {
        while(KEY)
        Delay_ms(10);
        }                  

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:127575 发表于 2016-6-21 17:11 | 只看该作者
完全不知道问题出在哪,各位大神帮帮忙,或者能提供一份已经调试成功的51版本ST7567LCD驱动,小弟感激不尽

回复

使用道具 举报

板凳
ID:748788 发表于 2023-4-16 17:08 | 只看该作者
程序没错,编译下载可用
回复

使用道具 举报

地板
ID:996773 发表于 2023-4-17 10:47 | 只看该作者
还是自己写一个吧,驱动12864是基本功,这个不会自己写,路很难走
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表