8515和LCD的接口源程序"/> PA0//LCD的RW->PA1//LCD的E->PA0//!!注意V" />

浓毛老太交欧美老妇热爱乱,蜜臀性色av免费,妺妺窝人体色www看美女,久久久久久久久久久大尺度免费视频,麻豆人妻无码性色av专区

位置:51電子網(wǎng) » 技術(shù)資料 » 單 片 機

ICCAVR->8515和LCD的接口源程序

發(fā)布時間:2007/9/10 0:00:00 訪問次數(shù):826

AVR8515 和 HD74480字符LCD的接口程序
//
//    硬件連接方式:LCD的D0-D7接8515的c口,
//                  LCD的 RS ->PA0
//                  LCD的 RW ->PA1
//                  LCD的 E  ->PA0
//    。!注意VEE,有時需要接負電源
---------------------------------------------------------------------
#include

#define RS_H  asm("sbi 0x1B,0")
#define RS_L  asm("cbi 0x1B,0")
#define RW_H  asm("sbi 0x1B,1")
#define RW_L  asm("cbi 0x1B,1")
#define E_H   asm("sbi 0x1b,2")
#define E_L   asm("cbi 0x1b,2")

//******************************************
void Delay()
{
     unsigned char di;
     for(di=0;di<20;di++);
}

//判斷l(xiāng)cd是否是內(nèi)部操作狀態(tài)
char Lcd_Busy()
{
        char rb;
    
        DDRC=0x0;   //端口c設(shè)為輸入方式
        E_L;
     RS_L;
    RW_H;
    Delay();
    E_H;
    Delay();
    rb=PINC;
    rb=rb&0x80;
    E_L;
    DDRC=0xff;  //端口c設(shè)為輸出方式

    return rb;
}


//向Lcd發(fā)送命令程序
void Lcd_Command(unsigned char bComm)
{
    while(Lcd_Busy());
    E_L;
     RS_L;
    RW_L;
    Delay();
    E_H;
    PORTC=bComm;
    Delay();
    E_L;
    Delay();

}

//向lcd寫入一個字符
void Lcd_Write(char wb)
{
    while(Lcd_Busy());
    E_L;
     RS_H;
    RW_L;
    Delay();
    E_H;
    PORTC=wb;
    Delay();
    E_L;
    Delay();
}

//初始化時用的寫命令程序,和Lcd_Command的區(qū)別是不判斷忙標志
void Lcd_InitCommand(unsigned char bComm)
{
    E_L;
     RS_L;
    RW_L;
    Delay();
    E_H;
    PORTC=bComm;
    Delay();
    E_L;
}

//初始化:8位接口,2行x16字符的工作方式
void Lcd_Init()
{
  char i;
  Lcd_InitCommand(0x30);
  for(i=0;i<100;i++) Delay();
  Lcd_InitCommand(0x30);
  for(i=0;i<10;i++) Delay();
  Lcd_InitCommand(0x30);

  Lcd_Command(0x38);
  Lcd_Command(0x08);
  Lcd_Command(0x01);
  Lcd_Command(0x06);
  Lcd_Command(0x02);
  Lcd_Command(0x0E);
}

//一個測試LCD的小程序
int main()
{
  
  const char *str="Hello,This is Dai in HIT.";

  DDRA=0xFF;
  DDRC=0xFF;
  
  Lcd_Init();

  while(*str)   Lcd_Write( *str++ );

  while(1);

AVR8515 和 HD74480字符LCD的接口程序
//
//    硬件連接方式:LCD的D0-D7接8515的c口,
//                  LCD的 RS ->PA0
//                  LCD的 RW ->PA1
//                  LCD的 E  ->PA0
//    。!注意VEE,有時需要接負電源
---------------------------------------------------------------------
#include

#define RS_H  asm("sbi 0x1B,0")
#define RS_L  asm("cbi 0x1B,0")
#define RW_H  asm("sbi 0x1B,1")
#define RW_L  asm("cbi 0x1B,1")
#define E_H   asm("sbi 0x1b,2")
#define E_L   asm("cbi 0x1b,2")

//******************************************
void Delay()
{
     unsigned char di;
     for(di=0;di<20;di++);
}

//判斷l(xiāng)cd是否是內(nèi)部操作狀態(tài)
char Lcd_Busy()
{
        char rb;
    
        DDRC=0x0;   //端口c設(shè)為輸入方式
        E_L;
     RS_L;
    RW_H;
    Delay();
    E_H;
    Delay();
    rb=PINC;
    rb=rb&0x80;
    E_L;
    DDRC=0xff;  //端口c設(shè)為輸出方式

    return rb;
}


//向Lcd發(fā)送命令程序
void Lcd_Command(unsigned char bComm)
{
    while(Lcd_Busy());
    E_L;
     RS_L;
    RW_L;
    Delay();
    E_H;
    PORTC=bComm;
    Delay();
    E_L;
    Delay();

}

//向lcd寫入一個字符
void Lcd_Write(char wb)
{
    while(Lcd_Busy());
    E_L;
     RS_H;
    RW_L;
    Delay();
    E_H;
    PORTC=wb;
    Delay();
    E_L;
    Delay();
}

//初始化時用的寫命令程序,和Lcd_Command的區(qū)別是不判斷忙標志
void Lcd_InitCommand(unsigned char bComm)
{
    E_L;
     RS_L;
    RW_L;
    Delay();
    E_H;
    PORTC=bComm;
    Delay();
    E_L;
}

//初始化:8位接口,2行x16字符的工作方式
void Lcd_Init()
{
  char i;
  Lcd_InitCommand(0x30);
  for(i=0;i<100;i++) Delay();
  Lcd_InitCommand(0x30);
  for(i=0;i<10;i++) Delay();
  Lcd_InitCommand(0x30);

  Lcd_Command(0x38);
  Lcd_Command(0x08);
  Lcd_Command(0x01);
  Lcd_Command(0x06);
  Lcd_Command(0x02);
  Lcd_Command(0x0E);
}

//一個測試LCD的小程序
int main()
{
  
  const char *str="Hello,This is Dai in HIT.";

  DDRA=0xFF;
  DDRC=0xFF;
  
  Lcd_Init();

  while(*str)   Lcd_Write( *str++ );

  while(1);

相關(guān)IC型號

熱門點擊

 

推薦技術(shù)資料

硬盤式MP3播放器終級改
    一次偶然的機會我結(jié)識了NE0 2511,那是一個遠方的... [詳細]
版權(quán)所有:51dzw.COM
深圳服務(wù)熱線:13751165337  13692101218
粵ICP備09112631號-6(miitbeian.gov.cn)
公網(wǎng)安備44030402000607
深圳市碧威特網(wǎng)絡(luò)技術(shù)有限公司
付款方式


 復(fù)制成功!