微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > 为什么这个程序我的12864液晶上面什么都没有 连光标也没有 求大神帮忙

为什么这个程序我的12864液晶上面什么都没有 连光标也没有 求大神帮忙

时间:10-02 整理:3721RD 点击:
#include<reg52.h>
#define uchar unsigned char
#define uint  unsigned  int
uchart , temp,dat;
sbit RW=P2^5;
sbit RS=P2^6;
sbit E=P2^7;
sbit   psb=P3^2;
sbit   psb1=P3^3;
void Delay10ms();
void Delay10ms(uint c)  
{
    uchar a,b;
        for (; c>0; c--)
        {
                 for (b=199;b>0;b--)
                 {
                          for(a=1;a>0;a--);
                 }      
        }
           
}
void read_busy()   //?12864?
{
uchar t;
E=0;
P0=0xff;//?
RS=0;
RW=1;
E=1;
Delay10ms(10);
t=P0;
while((t&0x80)==0x80)
{
  t=P0;
}
E=0;
}
void  writetemp(uchar  temp)
{
          read_busy();
    RS=0;
          RW=0;
          E=0;
          P0=temp;
        Delay10ms(10);  //yanshi
    E=1;
       Delay10ms(10); //yanshi
         E=0;

}
void  writedat(uchar  dat)
{
        read_busy();
    RS=1;
         RW=0;
          E=0;
          P0=dat;
            Delay10ms(10);     //yanshi
          E=1;
           Delay10ms(10);      //yanshi
       
       
       
         E=0;
       


}
void  init(void)
{  
       
       
   psb=1;
psb1=0;
   Delay10ms(50);
        psb1=1;
Delay10ms(50);
        writetemp(0x30);
        Delay10ms(50);
writetemp(0x30);
Delay10ms(50);
writetemp(0x0f);
Delay10ms(50);
writetemp(0x01);
Delay10ms(50);
writetemp(0x06);
Delay10ms(50);
}
void  main()
{
   init();
        while(1)
        {
  }
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top