标题: 单片机控制12864显示出现一个奇怪的问题,大神们请帮分析 [打印本页]

作者: kissme    时间: 2019-2-23 17:57
标题: 单片机控制12864显示出现一个奇怪的问题,大神们请帮分析
12864我用的串口。三根线接在下载端口也就是P3的0,1,2口。下载程序后能正常显示,但是不能拔下载线,拔掉就停止显示。百思不得解。考虑是不是把12864的线接在下载端口的缘故?于是我把12864的接线接到了P2口的5,6,7.更改程序的位定义后下载。无法显示。。。检查无数遍接线和程序。无果。。百般无聊中把另一12864屏插到原先的P3口。。。。结果  。结果。。P2口的12864正常显示了。又试着把程序改到P3口显示。P2口屏不动。。P3口的也正常显示,也可以拔下下载线了。。但是  ,P2口的12864就是不能拔。。拔掉就停止显示。。。也就是说,想正常拔下下载线显示。必须插2个12864。用其中一个正常显示。。。这是神马鬼?请大神赐教。。。谢谢
作者: wulin    时间: 2019-2-24 11:03
外接1~10K上拉电阻试试。
作者: yoxi    时间: 2019-2-24 12:59
代码放上来解析解析
作者: kissme    时间: 2019-2-24 14:34
wulin 发表于 2019-2-24 11:03
外接1~10K上拉电阻试试。

12864三根接线么?我试试
作者: kissme    时间: 2019-2-24 14:35
yoxi 发表于 2019-2-24 12:59
代码放上来解析解析

#include<intrins.h>
#define uchar unsigned char
sbit cs=P2^5;
sbit sid=P2^6;
sbit sck=P2^7;
//22.114
void yan(int w)   //100US
{
   int a,b;
    for(b=w;b>0;b--)
        for(a=2000;a>0;a--);
}

uchar   hanzi[]={"ÄÇË-£¿"};
uchar  hanzi0[]={"×òííÎòÃÎμ½Äã"};
uchar  hanzi1[]={"áË£¬¿ãñéêaáËò»"};
uchar  hanzi2[]={"′󯬡£"};

uchar  hanzi3[]={"½ñììííéÏ£¬Äã¸ú"};
uchar  hanzi4[]={"Îò×ߣ¬Ô¼ò»Åú¡£"};
uchar  hanzi5[]={"Ã÷ÔçèÃÄã¿T×Åà′éÏ"};
uchar  hanzi6[]={"°à¡£"};

uchar  hanzi7[]={"¾íÔú½ñíí"};
uchar  hanzi8[]={"oì2¨"};

void xie(uchar cdat)
{
         uchar a;
         for(a=0;a<8;a++)
         {
                 sck=1;
                 if(cdat&0x80)
                 {sid=1;}
                 else
                 {sid=0;}
                 cdat=cdat<<1;
                 sck=0;
                 //yan(10);
         }
}
void xiecom(uchar com)
{
         cs=1;
         xie(0xf8);
         xie(0xf0&com);
   xie(0xf0&com<<4);
         cs=0;
}
void xiedat(uchar dat)
{
         cs=1;
         xie(0xfa);
         xie(0xf0&dat);
         xie(0xf0&dat<<4);
         cs=0;
}

void pos(uchar x,uchar y)
{
        uchar poos;
   if (x==0)
     {x=0x80;}
   else if (x==1)
     {x=0x90;}
   else if (x==2)
     {x=0x88;}
   else if (x==3)
     {x=0x98;}
        poos=x+y;
        xiecom(poos);
}
        
void intc()
{
        xiecom(0x30);
        yan(100);
        xiecom(0x0c);
        yan(100);
        xiecom(0x01);
        yan(100);
        xiecom(0x06);
        yan(100);
}
        
void main()
{
uchar t;
  P2M1=0X00;
        P2M0=0x00;
         intc();
        yan(100);
while(1)
{
        
               
pos(0,0);
        t=0;
        while(hanzi[t]!='\0')
        {
                xiedat(hanzi[t]);
          t++;
          yan(100);
        }
                pos(1,1);
        t=0;
        while(hanzi0[t]!='\0')
        {
                xiedat(hanzi0[t]);
          t++;
                yan(100);
        }
        pos(2,0);
        yan(100);
        t=0;
        while(hanzi1[t]!='\0')
        {
                xiedat(hanzi1[t]);
          t++;
                yan(100);
        }
        pos(3,0);
        yan(100);
        t=0;
        while(hanzi2[t]!='\0')
        {
                xiedat(hanzi2[t]);
          t++;
                yan(100);
        }


        xiecom(0x01);
        yan(200);
        
               
pos(0,0);
        yan(100);
        t=0;
        while(hanzi3[t]!='\0')
        {
                xiedat(hanzi3[t]);
          t++;
          yan(100);
        }
                pos(1,0);
        yan(100);
        t=0;
        while(hanzi4[t]!='\0')
        {
                xiedat(hanzi4[t]);
          t++;
                yan(100);
        }
        pos(2,0);
        yan(100);
        t=0;
        while(hanzi5[t]!='\0')
        {
                xiedat(hanzi5[t]);
          t++;
                yan(100);
        }
        
        pos(3,0);
        yan(100);
        t=0;
        while(hanzi6[t]!='\0')
        {
                xiedat(hanzi6[t]);
          t++;
                yan(100);
        }
  xiecom(0x01);
        yan(300);
        
        pos(1,2);
        yan(100);
        t=0;
        while(hanzi7[t]!='\0')
        {
                xiedat(hanzi7[t]);
          t++;
                yan(200);
        }
        
        pos(3,5);
        yan(100);
        t=0;
        while(hanzi8[t]!='\0')
        {
                xiedat(hanzi8[t]);
          t++;
                yan(200);
        }
        xiecom(0x01);
        yan(2000);
}

}

作者: kissme    时间: 2019-2-24 15:02
wulin 发表于 2019-2-24 11:03
外接1~10K上拉电阻试试。

十分感谢你大神。。。12864三根线我接了上拉4.7K,完美解决




欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1