⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s1d13700.c

📁 基于8051的EPSON 13700的320*240液晶驱动程序
💻 C
📖 第 1 页 / 共 4 页
字号:
    


//-----------------------------------
// Pattern
//-----------------------------------
// 
uchar code Pat_AllOn[]={   0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                           0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                           0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
                           0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
uchar code Pat_AllOff[]={  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,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,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};



//-----------------------------------
// Delay Routine
//-----------------------------------
void delayms(uint m)        // 12MHz Xtal, close to ms value
{
    uint j;
    uint i;
    
    for(i=0; i<m; i++)
        for(j=0; j<109; j++)
            _nop_();
}



//-----------------------------------
// IO Routine
//-----------------------------------
void SdCmd(uchar Command)   //send command
{
    _WR = 1;                // init all control signal
    _RD = 1;
    A0  = 1;                // for command
    LCDBUS = Command;
    _CS = 0;                // enable the access
    _nop_();
    _WR = 0;
    _nop_();
    _nop_();
    _WR = 1;
    _nop_();
    _CS = 1;                // disable the access
    delayms(1);
}



void SdData(uchar DData)    //send display data
{
    _WR = 1;                // init all control signal
    _RD = 1;
    A0  = 0;                // for diaplay data
    LCDBUS = DData;
    _CS = 0;                // enable the access
    _nop_();
    _WR = 0;
    _nop_();
    _nop_();
    _WR = 1;
    _nop_();
    _CS = 1;                // disable the access
    _nop_();
    _nop_();
}



//-----------------------------------
// Write a Screen
//-----------------------------------
void WriteGraphicScreen(uchar *GDData)
// DisplayData should be 320x240/8 = 9600byte
// set to graphic display
{
    uchar           TempData;
    unsigned int    i;

    SdCmd(0x46);                    // CSRW
        SdData(0x00); SdData(0x00); // 2 para
    SdCmd(0x42);                    // MWRITE

    for(i=0;i<9600;i++)
    {
        TempData=(*(GDData+i));
        SdData(TempData);
    }
}



//-----------------------------------
// Write a Pattern Screen
//-----------------------------------
void WritePatternScreen(uchar *GDData)
// DisplayData should be 320x2/8 = 80byte
// set to graphic display
{
    uchar TempData;
    uchar i, j;

    SdCmd(0x46);                        // Set Cursor Add (2 byte parmeter)
    SdData(0x00);                       // starting location LSB
    SdData(0x00);                       // starting location MSB

    SdCmd(0x42);                        // MEMWRITE start writing data
    for(i=0;i<120;i++)
        {
        for(j=0;j<80;j++)
            {
            TempData=(*(GDData+j));
            SdData(TempData);
            }
        }
}



//-----------------------------------
// Init LCD module
//-----------------------------------
void initLCDM(void)
{
    _RES    = 1;    // reset pin
    _RES    = 0;
    delayms(5);
    _RES    = 1;
    delayms(10);

    SdCmd(0x40);    //System set (8 byte parameter)
    SdData(0x30);   // IV=1(no line comp),ws=0(single drv),M2=0(8bit char height),M0=0(int CGROM), D4=1(by default)                    
    SdData(0x87);   // MOD=1 two frame AC drv, HorChar Size=8
    SdData(0x07);   // VerChar Size=8
    SdData(0x28);   // (320/8=40) char per line
    SdData(0x47);   // 23+blanking (frame freq = 66Hz (clk ratio=1/4  @ 10MHz)
    SdData(0xEF);   // (240-1=239) line per screen
    SdData(0x28);   // Virtual screen width LSB
    SdData(0x00);   // Virtual screen width MSB
    
    SdCmd(0x59);    // Display ON/OFF(1 byte parameter)
    SdData(0x04);   // SAD1=on, cursor=off
        
    SdCmd(0x44);    //Scroll (10 byte parmeter)
    SdData(0x00);   // SAD1 start ADD LSB
    SdData(0x00);   // SAD1 start ADD MSB
    SdData(0xEF);   // SAD1 block size(no.of line-1)
    SdData(0x00);   // SAD2 start ADD LSB 
    SdData(0x00);   // SAD2 start ADD MSB
    SdData(0xEF);   // SAD2 block size(no.of line-1)
    SdData(0x00);   // SAD3 start ADD LSB
    SdData(0x00);   // SAD3 start ADD MSB
    SdData(0x00);   // SAD4 start ADD LSB
    SdData(0x00);   // SAD4 start ADD MSB
    
    SdCmd(0x5D);    //CSRFORM (2 byte parmeter)
    SdData(0x07);   // cursor width = 8
    SdData(0x17);   // CM=1, for graphic mode, cursor height = 8        
    
    SdCmd(0x4C);    // CSRDIR (0 byte parmeter) to the right side

    SdCmd(0x5B);    // OVLAY (1 byte parmeter)
    SdData(0x05);   // 0v=0(2layer),DM1=0(blk3 for text),DM0=1(blk1 for graphic),layers combine=01(XOR) 

/*  SdCmd(0x5C);    // CGRAMADR (2 byte parmeter)
    SdData(0x00);
    SdData(0x00);
*/
    SdCmd(0x5A);    // HDOT SCR (1 byte parmeter)
    SdData(0x00);   // no scroll

    SdCmd(0x60);    // GRAYSCALE (1 byte parmeter)
    SdData(0x00);   // 1bpp
}



//-----------------------------------
// Main Program
//-----------------------------------
void main()
{
    SP=0x60;
    EA = 0;                 // disable interrupts

    _RES    = 1;            // init all signal
    _CS     = 1;
    _RD     = 1;
    _WR     = 1;
    A0      = 1;
    LCDBUS  = 0xff;         // pull up data bus

    initLCDM();

    while(1)
    {
    WriteGraphicScreen(GraphicLogo);    delayms(500);
    WritePatternScreen(Pat_AllOn);      delayms(500);
    WritePatternScreen(Pat_AllOff);     delayms(500);
    }
}
//end of program

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -