在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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首頁 > 光電顯示 > 設計應用 > 12864液晶(AVR_Mega128)的頭文件

            12864液晶(AVR_Mega128)的頭文件

            作者: 時間:2018-08-09 來源:網(wǎng)絡 收藏

            大家使用時把這段代碼保存成.h的頭文件,在主程序中包含這個頭文件就行

            本文引用地址:http://www.biyoush.com/article/201808/386090.htm

            根據(jù)你們液晶電路更改下面的端口宏定義即可

            //CPU:ATmega128; 時鐘頻率為16MHz

            //編譯環(huán)境為ICCAVR

            //頭文件

            #include

            #include

            #include

            //數(shù)據(jù)端口定義

            #define Dat_Port_Write PORTA

            #define Dat_Port_Read PINA

            //控制端口及相應的位

            #define RS_RW_EN_Control PORTG

            #define LCM_RS 0

            #define LCM_RW 1

            #define LCM_EN 2

            #define uchar unsigned char

            #define uint unsigned int

            //延時函數(shù)

            void Delay_Ms(unsigned int ms)

            {

            for(;ms>1;ms--);

            }

            //寫數(shù)據(jù)

            void Write_Data_LCM(unsigned char WDLCM)

            {

            Read_Status_LCM(); //檢測忙

            Delay_Ms(100);

            RS_RW_EN_Control|=BIT(LCM_RS); //RS=1

            Delay_Ms(100);

            RS_RW_EN_Control=~BIT(LCM_RW); //RW=0

            Delay_Ms(100);

            RS_RW_EN_Control|=BIT(LCM_EN); //EN=1

            Delay_Ms(100);

            Dat_Port_Write=WDLCM; //輸出數(shù)據(jù)

            Delay_Ms(100);

            RS_RW_EN_Control=~BIT(LCM_EN); //EN=0

            Delay_Ms(100);

            }

            //寫指令

            void Write_Command_LCM(unsigned char WCLCM)

            {

            Read_Status_LCM(); //根據(jù)需要檢測忙

            Delay_Ms(100);

            RS_RW_EN_Control=~BIT(LCM_RS); //RS=0

            Delay_Ms(100);

            RS_RW_EN_Control=~BIT(LCM_RW); //RW=0

            Delay_Ms(100);

            RS_RW_EN_Control|=BIT(LCM_EN); //EN=1

            Delay_Ms(100);

            Dat_Port_Write=WCLCM; //輸出指令

            Delay_Ms(100);

            RS_RW_EN_Control=~BIT(LCM_EN); //EN=0

            Delay_Ms(100);

            }

            //讀狀態(tài):檢測忙

            void Read_Status_LCM(void)

            {

            uchar temp;

            uchar flag = 1;

            while(flag==1)

            {

            DDRA=0x00; //端口A改為輸入

            Dat_Port_Write = 0xff;

            Delay_Ms(100);

            RS_RW_EN_Control=~BIT(LCM_RS); //RS=0

            Delay_Ms(100);

            RS_RW_EN_Control|=BIT(LCM_RW); //RW=1

            Delay_Ms(100);

            RS_RW_EN_Control|=BIT(LCM_EN); //EN=1

            Delay_Ms(100);

            temp = Dat_Port_Read; //讀端口A

            Delay_Ms(100);

            DDRA=0xff; //端口A改為

            Delay_Ms(100);

            RS_RW_EN_Control=~BIT(LCM_EN); //EN=0

            Delay_Ms(100);

            if(temp>>7==0)

            flag = 0;

            }

            }

            //LCM初始化

            void LCM_Init(void)

            {

            Write_Command_LCM(0x38); //三次顯示模式設置,不檢測忙信號

            Delay_Ms(1000);

            Write_Command_LCM(0x38);

            Delay_Ms(1000);

            Write_Command_LCM(0x38);

            Delay_Ms(1000);

            Write_Command_LCM(0x38); //顯示模式設置,開始要求每次檢測忙信號

            Write_Command_LCM(0x08); //關閉顯示

            Write_Command_LCM(0x01); //顯示清屏

            Write_Command_LCM(0x06); //顯示光標移動設置

            Write_Command_LCM(0x0C); //顯示開及光標設置

            }

            /



            關鍵詞:

            評論


            相關推薦

            技術專區(qū)

            關閉