lcd1602.rar

  • wuujingoo
    了解作者
  • C/C++
    开发工具
  • 1KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 3
    下载次数
  • 2012-09-19 22:58
    上传日期
LCD1602驱动 很好用哦 字数有要求好烦 能不能不要这样啊
lcd1602.rar
  • lcd1602.c
    3.4KB
内容介绍
void CLR_SCREEN(void); void LCD_DISOFF(void); void LCD_DISON(void); void LCD_CUROFF(void); void LCD_CURON(void); void LCD_INT(void); void LCD_PRINT(unsigned char row,unsigned char col,unsigned char count,unsigned int dats); void LCD_PRINTF(unsigned char row,unsigned char col,signed char InBuffer[33]); void CPU_DELAYTIME(unsigned int count); void CHK_BUSY(void); void LCD_WRI(unsigned char adr); void LCD_WRD(unsigned char asc); //--------------------------------------------------显示数值 void LCD_PRINT(unsigned char row,unsigned char col,unsigned char count,unsigned int dats){ unsigned int sxh4; unsigned int sxh3; unsigned int sxh2; unsigned int sxh1; LCD_DISON(); CPU_DELAYTIME(100); switch (row) { case 1:row=0x80;break; case 2:row=0xC0;break; default: break; } LCD_WRI(row+col-1); CPU_DELAYTIME(2000); sxh4=dats/10; sxh3=sxh4/10; sxh2=sxh3/10; sxh1=sxh2/10; if(count>=5){LCD_WRD(sxh1+48);} if(count>=4){LCD_WRD(sxh2-sxh1*10+48);} if(count>=3){LCD_WRD(sxh3-sxh2*10+48);} if(count>=2){LCD_WRD(sxh4-sxh3*10+48);} LCD_WRD(dats-sxh4*10+48); } //--------------------------------------------------LCD初始化 void LCD_INT(void){ LCD_WRI(0X38); //8位数据总线 两行显示模式 5X7点阵+光标显示模式 LCD_CUROFF(); //无光标跟随 LCD_WRI(0X80); //设置显示地址00H } //--------------------------------------------------关闭显示 void LCD_DISOFF(void){ LCD_WRI(0X08); } //--------------------------------------------------打开显示 void LCD_DISON(void){ LCD_WRI(0X0C); } //--------------------------------------------------光标消失 void LCD_CUROFF(void){ LCD_WRI(0X0C); } //--------------------------------------------------光标跟随 void LCD_CURON(void){ LCD_WRI(0X0F); } //--------------------------------------------------显示字符串 void LCD_PRINTF(unsigned char row,unsigned char col,signed char InBuffer[33]) { unsigned char I_LOOP; LCD_DISON(); CPU_DELAYTIME(500); switch (row) { case 1:row=0x80;break; case 2:row=0xC0;break; default: break; } LCD_WRI(row+col-1); for(I_LOOP=0;I_LOOP<=32;I_LOOP++){ if(InBuffer[I_LOOP]=='%'&&InBuffer[I_LOOP+1]=='d'){ break;} if(col+I_LOOP==15&&row==0x80){LCD_WRI(0xC0);} LCD_WRD(InBuffer[I_LOOP]); } } //--------------------------------------------------检查忙位 void CHK_BUSY() { LCD_RW=1; TRISP=0x00; LCD_RS=0; LCD_E=1; TRISP=0xff; LCD_DAT=0xff; while((LCD_DAT&0x80)==0x80); TRISP=0xFF; LCD_E=0; } //-------------------------------------------------清屏指令 void CLR_SCREEN(void){ LCD_INT(); LCD_WRI(1); CPU_DELAYTIME(2000); } //-------------------------------------------------延时函数 void CPU_DELAYTIME(unsigned int count){ unsigned int iu_LOOP; for(iu_LOOP=0;iu_LOOP<=count;iu_LOOP++){ asm{ nop } } } //-----------------------------------------------显示屏写指令子程序 void LCD_WRI(unsigned char adr) { // CHK_BUSY(); TRISP=0XFF; LCD_RW=0; LCD_RS=0; LCD_E=1; LCD_DAT=adr; LCD_E=0; CPU_DELAYTIME(1000); } //----------------------------------------------显示屏写数据子程序 void LCD_WRD(unsigned char asc) {// CHK_BUSY(); TRISP=0XFF; LCD_RW=0; LCD_RS=1; LCD_E=1; LCD_DAT=asc; LCD_E=0; CPU_DELAYTIME(800); }
评论
    相关推荐