新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > 1602液晶萬能驅動程序

        1602液晶萬能驅動程序

        作者: 時間:2016-11-29 來源:網絡 收藏
        #define mcu_pic
        //單片機種類選擇  mcu_avr  mcu_51  mcu_pic mcu_msp430/******************************************/#define uchar unsigned char/**************************************************/#ifdef mcu_avr                 //單片機種類  avr#include "iom8535v.h"             //型號頭文件#define PORT       PORTC         //端口寄存器#define PORT_OUT  (DDRC=0XFF)       //輸出配置#define PORT_IN   (DDRC=0X00)       //輸入配置#define PORT_INT  PINC              //端口狀態#define rs(x)    (x?(PORTA|=0x01):(PORTA&=0xfe))#define rw(x)    (x?(PORTA|=0x02):(PORTA&=0xfd))#define e(x)     (x?(PORTA|=0x04):(PORTA&=0xfb))#define rs_rw_e_output (DDRA = 0X07)//輸出配置#endif/**************************************************//**************************************************/#ifdef mcu_51               //單片機種類  51#include "REG51.h"              //型號頭文件#define PORT       P3           //端口寄存器#define PORT_OUT  (P3=0X00)       //輸出配置#define PORT_IN   (P3=0XFF)       //輸入配置#define PORT_INT  P3              //端口狀態#define rs(x)    (x?(P1|=0x20):(P1&=0xDF))#define rw(x)    (x?(P1|=0x40):(P1&=0xBF))#define e(x)     (x?(P1|=0x80):(P1&=0x7F))#define rs_rw_e_output (P1 = 0XE0)//輸出配置//#define PORT P3//sbit rs=P2^0;//sbit rw=P2^1;//sbit e=P2^2;#endif/**************************************************//**************************************************/#ifdef mcu_pic                //單片機種類  pic#define _16F877                #include               //型號頭文件#define PORT       PORTD        //端口寄存器#define PORT_OUT  (TRISD=0X00)       //輸出配置#define PORT_IN   (TRISD=0XFF)       //輸入配置#define PORT_INT   PORTD             //端口狀態#define rs(x)  (x?(PORTC|=0X01):(PORTC&=0XFE))#define rw(x)  (x?(PORTC|=0X02):(PORTC&=0XFd))#define e(x)   (x?(PORTC|=0X04):(PORTC&=0XFb))#define rs_rw_e_output (TRISC &= 0XF8)//輸出配置#endif#ifdef mcu_msp430              #include"msp430x21x1.h"#define PORT       P1OUT       #define PORT_OUT  (P1DIR=0XFF)     #define PORT_IN   (P1DIR=0X00)      #define PORT_INT   P1IN           #define rs(x)  (x?(P2OUT|=0X01):(P2OUT&=0XFE))#define rw(x)  (x?(P2OUT|=0X02):(P2OUT&=0XFd))#define e(x)   (x?(P2OUT|=0X04):(P2OUT&=0XFb))#define rs_rw_e_output (P2DIR = 0X07)#endif/**************************************************//**************************************00000  5*7  -> 0xff*****0** /5*8     0x40*****0**    0x40  ----> I*****0**    0x40  ---->*****0**    0x40*****0**    0x40***00000    0x1f添加自己的自定義字符***********************************/uchar ziku[]={0x04,0x05,0x06,0x07,0x13,0x16,0X15,0x0C,0xff,0xff,0x55,0xff,0x55,0xff,0xff,0xff};/*************************************函數聲明區*************************************/uchar lcd_readcom(void);void  check_busy(void);void  lcd_writecom(uchar dat);uchar lcd_readdat(void);void  lcd_writedat(uchar dat);void lcd_gets(const uchar *dat);void  lcd_xy(uchar x,uchar y);void  lcd_init(void);/*******************************讀取lcd1602狀態  *******************************/uchar lcd_readcom(void){uchar temp;e(0);PORT_IN;rs(0);rw(1);e(1);temp=PORT_INT;e(0);PORT_OUT;return temp;}/***************************************檢測 lcd 是否忙碌   阿飛天天忙綠***************************************/void check_busy(void){uchar temp;do{temp=lcd_readcom();}while((temp&0x80)==0x80);}				   
        				
                    
                        
        			
        							
        上一頁 1 2 下一頁

        關鍵詞: 1602液晶萬能驅

        評論


        技術專區

        關閉
        主站蜘蛛池模板: 安西县| 乌海市| 鲁甸县| 库伦旗| 青浦区| 定兴县| 长岛县| 青铜峡市| 诏安县| 宁晋县| 嘉兴市| 汕头市| 哈巴河县| 德庆县| 德格县| 昭觉县| 兴文县| 宝兴县| 佛山市| 华安县| 呼伦贝尔市| 鄱阳县| 上饶县| 邢台县| 左权县| 施秉县| 阳谷县| 高邑县| 灵武市| 南澳县| 巨鹿县| 新兴县| 扎鲁特旗| 德格县| 巴林左旗| 蕲春县| 全州县| 永善县| 合阳县| 江华| 怀来县|