在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 自制51單片機(jī)常用頭文件(st7920并行方式)

            自制51單片機(jī)常用頭文件(st7920并行方式)

            作者: 時間:2016-11-10 來源:網(wǎng)絡(luò) 收藏
            /*--------------------------------------------------------------------------

            ST7920.H

            本文引用地址:http://www.biyoush.com/article/201611/317350.htm

            The user function is C51.
            Copyright (c) 1988-2004 Keil Elektronik GmbH sum zhaojun
            All rights reserved.
            --------------------------------------------------------------------------*/
            // 并行方式
            #ifndef __ST7920_H__
            #define __ST7920_H__

            #define uchar unsigned char
            #define uint unsigned int

            sbit LCD_RS = P3^2; // 指令/數(shù)據(jù)選擇
            sbit LCD_RW = P3^3; // 并行讀寫選擇信號
            sbit LCD_EN = P3^4; // 并行使能信號
            sbit LCD_PSB = P3^5; // 并/串選擇端口:H - 并行;L - 串行
            sbit LCD_RES = P3^6;// LCD復(fù)位,LCD模塊自帶復(fù)位電路??刹唤?/p>

            #define LCD_DATA P1 // MCU P1<------>LCM
            /*****************************************************
            函 數(shù) 名:void Delay_LCD(void)
            功 能:5ms延時
            入口參數(shù):無
            返 回 值:無
            ****************************************************/
            void Delay_LCD(uint t)
            {
            uint i,j;

            for (i=0; i{
            for (j=0; j<10; j++)
            {
            ;
            }
            }
            }
            /*****************************************************
            函 數(shù) 名:void WriteCommandLCM()
            功 能:向LCM中寫入指令
            入口參數(shù):WCLCM
            返 回 值:無
            ****************************************************/
            void WriteCommandLCM(uchar WCLCM)
            {
            LCD_RS = 0; // 選擇寫入指令
            LCD_RW = 0; // 寫入
            LCD_EN = 1; // 使能

            LCD_DATA = WCLCM; // 寫入指令
            LCD_EN = 0;
            Delay_LCD(5);
            }
            /*****************************************************
            函 數(shù) 名:void WriteDataLCM()
            功 能:向LCM1602中寫入數(shù)據(jù)
            說 明:將形參WDLCM中的數(shù)據(jù)寫入LCM中
            入口參數(shù):WDLCM
            返 回 值:無
            *****************************************************/
            void WriteDataLCM(uchar WDLCM)
            {
            LCD_RS = 1; // 選擇寫入數(shù)據(jù)
            LCD_RW = 0; // 寫入
            LCD_EN = 1; //

            LCD_DATA = WDLCM; // 寫入數(shù)據(jù)
            LCD_EN = 0;
            Delay_LCD(5);
            }
            /*****************************************************
            函 數(shù) 名:void LCMInit()
            功 能:初始化LCM
            說 明:LCM在工作前先要對顯示屏初始化,否則模塊無法正常工作
            入口參數(shù):無
            返 回 值:無
            *****************************************************/
            void LCMInit(void)
            {
            Delay_LCD(20);
            LCD_PSB = 1; // 選擇并行傳輸方式
            Delay_LCD(20);

            LCD_RES = 0; // 復(fù)位,可不要
            Delay_LCD(1);
            LCD_RES = 1;

            WriteCommandLCM(0x30); // 選擇基本指令集
            Delay_LCD(10);
            WriteCommandLCM(0x0c); // 開顯示(無游標(biāo)、反白)
            Delay_LCD(10);
            WriteCommandLCM(0x01); // 清顯示并設(shè)地址指針為00H
            Delay_LCD(50);
            }
            /*****************************************************
            函 數(shù) 名:void DisplayListChar()
            功 能:向指點(diǎn)的地址寫入字符串
            入口參數(shù):x-橫坐標(biāo),y-縱坐標(biāo),s-字符串
            返 回 值:無
            *****************************************************/
            void DisplayListChar(uchar x, uchar y, uchar code *s)
            {
            uchar add; // 顯示地址

            switch (y) // 顯示地址計(jì)數(shù)
            {
            case 0: add = x + 0x80; break; // 第一行的地址
            case 1: add = x + 0x90; break; // 第二行的地址
            case 2: add = x + 0x88; break; // 第三行的地址
            case 3: add = x + 0x98; break; // 第四行的地址
            default: break;
            }

            WriteCommandLCM(0x30); // 基本指令
            WriteCommandLCM(add); // 寫入地址

            while (*s > 0) // 寫入字符串
            {
            WriteDataLCM(*s);
            s++;
            Delay_LCD(50);
            }
            }

            /*****************************************************
            函 數(shù) 名:void DisplayPicture()
            功 能:寫入一幅128x64的圖片
            入口參數(shù):img - 圖片數(shù)組名
            返 回 值:無
            *****************************************************/
            //顯示圖片(圖片為公司名稱)
            void DisplayPicture(uchar code *img)
            {
            uint j = 0;
            uchar x,y;
            // -------------- 上半屏 ----------------
            for (y=0; y<32; y++) // 垂直坐標(biāo)32位
            {
            for (x=0; x<8; x++) // 水平坐標(biāo)16字節(jié)
            {
            WriteCommandLCM(0x36); // 擴(kuò)展指令
            WriteCommandLCM(y+0x80); // 先寫入垂直坐標(biāo)
            WriteCommandLCM(x+0x80); // 再寫入水平坐標(biāo)

            WriteCommandLCM(0x30); // 基本指令
            WriteDataLCM(img[j++]); // 連續(xù)寫入16位數(shù)據(jù)
            WriteDataLCM(img[j++]);
            }
            }
            // --------------- 下半屏 ---------------
            j = 512; // 下半屏起始數(shù)據(jù)

            for (y=0; y<32; y++) // 垂直坐標(biāo)32位
            {
            for (x=0; x<8; x++) // 水平坐標(biāo)16字節(jié)
            {
            WriteCommandLCM(0x36); // 擴(kuò)展指令
            WriteCommandLCM(y+0x80); // 先寫入垂直坐標(biāo)
            WriteCommandLCM(x+0x88); // 再寫入水平坐標(biāo)

            WriteCommandLCM(0x30); // 基本指令
            WriteDataLCM(img[j++]); // 連續(xù)寫入16位數(shù)據(jù)
            WriteDataLCM(img[j++]);
            }
            }
            }

            #endif



            評論


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

            關(guān)閉