打印

请问大侠们,单片机管脚之间有影响吗?

[复制链接]
2624|16
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
请问大侠们,单片机管脚之间有影响吗?
为什么我的P1脚输出会影响到P0口的输出呢?
我的电路图检查了,没看出有什么问题。
现在是LCD无显示,用别人正常使用的程序也不行。
后来测试发现P1脚输出会影响到平P0口的输出?
难道是因为这个问题,可能吗?

#include <at89s53.h>
#define uchar unsigned char
#define uint  unsigned int

void delay(uint x)
{
uint i, y;
for(i=0; i<x; i++)
for(y=0;y<104; y++);
}

void main()
{
P0 = 0x00;
delay(2000);
while(1)
{
P0 = 0x55;
P1=0x00;
P3=0x00;
delay(3000);
P0 = 0xAA;
P1=0x0F;//不可以0F,F7,1F等,不然P0口就有的不能输出高电平。
P3=0xFF;
delay(3000);
}
}

相关帖子

沙发
sunningning|  楼主 | 2011-6-11 21:41 | 只看该作者
电路图如下

1.jpg (257.65 KB )

1.jpg

使用特权

评论回复
板凳
云的追寻| | 2011-6-11 22:13 | 只看该作者
程序不完整啊。。。你先把12864的原理时序看懂吧

使用特权

评论回复
地板
fontlose| | 2011-6-12 08:56 | 只看该作者
先把完整的时许写好在测试,这样测没意义,RW脚你读的时候是12864做输出。

使用特权

评论回复
5
shell.albert| | 2011-6-12 11:44 | 只看该作者
还有此等神奇的事情?

使用特权

评论回复
6
nan_banqiu| | 2011-6-12 14:34 | 只看该作者
理论上 答案是否定的

使用特权

评论回复
7
sunningning|  楼主 | 2011-6-12 16:42 | 只看该作者
完整的程序测试,始终没有显示

#include <reg51.h>
#include <INTRINS.H>

//Data Type Re-defination
#define  uchar unsigned char
#define  uint unsigned int
#define  uchar_code unsigned char code

//MCU Interface Defination
sbit CS1=P3^5;
sbit CS2=P3^6;
sbit RS=P3^0;
sbit RW=P3^1;
sbit E=P3^4;
sbit RST=P3^7;


//Defination Border Dots Matrix
uchar_code border_inf[8] = {
        0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x80 };

uchar_code bmp_area[1024]=
{
0xFF,0x81,0xBD,0xA5,0xA5,0xBD,0xA1,0xBF,0xA0,0xA0,0xFF,0x01,0xFD,0xA5,0xA5,0xBD,
0x81,0xFF,0x00,0x00,0xFF,0x01,0x81,0x41,0x21,0xF1,0x01,0x01,0x01,0x01,0x41,0x21,
0x11,0x11,0x11,0x31,0xC1,0x01,0x01,0xC1,0x21,0x11,0x11,0x11,0x21,0xC1,0x01,0x01,
0x11,0x21,0xC1,0x01,0x01,0x01,0xC1,0x21,0x11,0x01,0x01,0xC1,0x21,0x11,0x11,0x11,
0x21,0x41,0x01,0x01,0x01,0x01,0x81,0x41,0x21,0xF1,0x01,0x01,0x01,0x01,0x09,0x89,
0xC9,0xA9,0x99,0x89,0x89,0x45,0x35,0x05,0x05,0x05,0x01,0x01,0x09,0x09,0x09,0xE9,
0x59,0x49,0x49,0xE9,0x49,0x01,0xE1,0x01,0x01,0xFD,0x01,0xFF,0x00,0x00,0xFF,0x81,
0xBD,0xA5,0xA5,0xFD,0x01,0xFF,0xA0,0xA0,0xBF,0xA1,0xBD,0xA5,0xA5,0xBD,0x81,0xFF,
0xFC,0x04,0xF4,0x94,0x94,0xFF,0x00,0xFF,0x04,0x04,0xFC,0x04,0x04,0x04,0x04,0x04,
0x04,0x04,0x04,0x04,0x07,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x80,0xC0,
0xA0,0x90,0x88,0x86,0x81,0x00,0x00,0x38,0x45,0x82,0x82,0x82,0x45,0x38,0x00,0x80,
0x40,0x20,0x18,0x05,0x02,0x05,0x18,0x20,0x40,0x80,0x00,0x3F,0x42,0x81,0x81,0x81,
0x42,0x3C,0x00,0x18,0x14,0x12,0x11,0x10,0x10,0xFF,0x10,0x00,0x00,0x00,0x84,0x4C,
0x26,0x16,0x05,0x05,0xFC,0x04,0x15,0x26,0x4C,0x88,0x00,0x00,0x04,0x02,0x81,0x42,
0x24,0x18,0x06,0x01,0x00,0x00,0x1F,0x80,0x00,0xFF,0x00,0x07,0x04,0x04,0x04,0x04,
0x04,0x04,0x04,0x04,0x04,0xFC,0x04,0x04,0xFF,0x00,0xFF,0x94,0x94,0xF4,0x04,0xFC,
0x03,0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0xF8,0x08,0x08,0x88,0x78,0xA8,0x28,0xA8,0x68,0x28,0x08,0x08,0xF8,0x00,0x00,
0x00,0x08,0x08,0xF8,0x08,0x08,0xF8,0x08,0x08,0x00,0x40,0x20,0x90,0x1C,0x08,0x00,
0x00,0x00,0x00,0x80,0x80,0x80,0x80,0xFC,0x90,0x90,0x90,0xD0,0x90,0x00,0x00,0x00,
0xF8,0x08,0x48,0xA8,0x18,0x20,0x20,0xE0,0x3C,0xA0,0x20,0x20,0x20,0x21,0x00,0x00,
0x40,0x84,0x19,0x82,0x61,0x10,0x90,0x70,0x10,0x95,0xF8,0x90,0x91,0x91,0x10,0x00,
0x00,0x00,0x00,0x00,0xF8,0xA8,0xA8,0xA8,0xA9,0xA8,0xA8,0xF8,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x03,0x02,0x02,0x02,0x02,0x02,0x02,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0xFF,0x09,0x09,0x04,0x04,0x22,0xC9,0x52,0x02,0x04,0x0C,0x04,0xFF,0x00,0x00,
0x01,0x01,0xC1,0x3F,0x01,0x01,0xFF,0x01,0x11,0x09,0x84,0x42,0x23,0x39,0x10,0x00,
0x00,0x00,0xC0,0x1F,0x48,0x88,0x08,0x28,0x48,0x88,0x08,0x3F,0x40,0x80,0x00,0x00,
0xFF,0x00,0x08,0x10,0x0F,0x12,0x13,0x12,0x12,0xFF,0x12,0x12,0x12,0x12,0x10,0x00,
0x10,0x11,0xFC,0x03,0x04,0x02,0xFF,0x04,0x86,0x49,0x32,0x6C,0x86,0x01,0x00,0x00,
0x00,0xFC,0x94,0x94,0x95,0x94,0xFC,0x00,0x00,0xFC,0x94,0x95,0x94,0x94,0xFC,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x03,0x01,0xF9,0xA9,0xA9,0xA9,0xA9,0xA9,0xA9,0xA9,0xF9,0x01,0x03,0x00,0x00,
0x02,0x81,0x80,0x88,0x88,0x88,0x89,0x88,0x8A,0x89,0x88,0x88,0x88,0x80,0x80,0x00,
0x40,0x41,0xFC,0x40,0x40,0x11,0xD0,0x50,0x7C,0x51,0x50,0x7C,0xD0,0x11,0x00,0x00,
0x43,0x40,0xFC,0x40,0x40,0x00,0x20,0x20,0xFC,0x23,0x20,0x20,0xE0,0x00,0x00,0x00,
0x20,0xC4,0x1B,0x80,0x00,0xF8,0x0B,0xC9,0x08,0xF8,0x00,0xE0,0x01,0x03,0xFD,0x00,
0x00,0x09,0x70,0x20,0x00,0x40,0x41,0x40,0x40,0x41,0xFC,0x40,0x48,0x70,0x41,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0xC0,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
0x80,0x84,0x88,0xB0,0x80,0xFF,0x80,0x80,0x80,0xFF,0xA0,0x90,0x8C,0x80,0x80,0x00,
0x40,0x20,0x10,0x0C,0x00,0x00,0x00,0xFF,0x00,0x00,0x04,0x08,0x30,0x60,0x00,0x00,
0x0C,0x03,0xFF,0x01,0x02,0x10,0x17,0x15,0xD5,0x3D,0x55,0x95,0x97,0x10,0x10,0x00,
0x20,0x60,0x3F,0x10,0x14,0x04,0xC4,0x34,0x0F,0x14,0x24,0x44,0xC7,0x84,0x84,0x00,
0x10,0xF0,0x0E,0x01,0x00,0x1F,0xC0,0x3F,0x40,0x9F,0x00,0x1F,0x00,0x00,0xFF,0x00,
0x01,0x01,0xFF,0x80,0x40,0x82,0x82,0x7E,0x42,0x42,0x07,0x18,0x60,0x80,0xE0,0x00,
0x00,0x00,0x00,0x00,0x00,0xFF,0x00,0x00,0xC0,0x40,0x40,0x40,0x40,0x40,0x40,0xC0,
0x3F,0x20,0x2F,0x29,0x29,0xFF,0x00,0xFF,0x20,0x20,0x3F,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0xE0,0x00,0x00,0x00,0x00,0x00,0x80,0x00,0xC0,0x00,0x80,0x00,
0x00,0x80,0x00,0xC0,0x00,0x81,0x02,0x01,0x80,0x00,0xC0,0x00,0x80,0x00,0x00,0x80,
0x00,0xC0,0x03,0x80,0x00,0x02,0x82,0x01,0xC0,0x00,0x80,0x00,0x01,0x83,0x01,0xC0,
0x00,0x80,0x00,0x00,0x82,0x01,0xC0,0x00,0x80,0x00,0x00,0x80,0x00,0xC1,0x00,0x80,
0x00,0x03,0x80,0x00,0xC2,0x01,0x80,0x00,0x00,0x81,0x00,0xC0,0x01,0x82,0x01,0x00,
0x80,0x00,0xC1,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x20,0x20,0x21,0x20,
0x20,0x20,0x20,0x20,0x20,0x3F,0x20,0x20,0xFF,0x00,0xFF,0x29,0x29,0x2F,0x20,0x3F,
0xFF,0x81,0xBD,0xA5,0xA5,0xBD,0x85,0xFD,0x05,0x05,0xFF,0x80,0xBF,0xA5,0xA5,0xBD,
0x81,0xFF,0x00,0x00,0xFF,0x80,0x80,0x80,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,
0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x84,
0x83,0x8F,0x83,0x84,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x84,0x83,0x8F,
0x83,0x84,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,
0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x84,0x83,0x8F,0x83,0x84,0x80,0x80,
0x84,0x83,0x8F,0x83,0x84,0x80,0x80,0x80,0x80,0x80,0x80,0xFF,0x00,0x00,0xFF,0x81,
0xBD,0xA5,0xA5,0xBF,0x80,0xFF,0x05,0x05,0xFD,0x85,0xBD,0xA5,0xA5,0xBD,0x81,0xFF
};

/*Check Busy Flag
void check_busy(void)
{
        RS=0;
        RW=1;
        P1=0Xff;
        while (1)
        {
                E=1;
                if (P1<0x80) break;
                E=0;
        }
        E=0;
}
End Function check_busy*/

//Delay Times(s Level)
#pragma disable
void delays(uint n)
{
        uint s;
        while (n-- >0)
                for (s=0;s<400;s++)
                {}
}

//Write Instruction Code
#pragma disable
void wr_cmd(uchar cmd)
{
        E=0;
        _nop_();
        _nop_();
        RS=0;
        _nop_();
        _nop_();
        RW=0;
        _nop_();
        _nop_();
        P1=cmd;
        _nop_();
        _nop_();
        E=1;
        _nop_();
        _nop_();
        E=0;
        _nop_();
        _nop_();
}

//Write Display RAM Data
#pragma disable
void wr_dat(uchar dat)
{
        E=0;
        _nop_();
        _nop_();
        RS=1;
        _nop_();
        _nop_();
        RW=0;
        _nop_();
        _nop_();
        P1=dat;
        _nop_();
        _nop_();
        E=1;
        _nop_();
        _nop_();
        E=0;
        _nop_();
        _nop_();
}

//S6B0108 Initial
#pragma disable
void initial()
{
        CS1=1;CS2=1;
        wr_cmd(0x3f); //Display On
        wr_cmd(0xb8);//Set Page Address(X Address)
        wr_cmd(0x40);//Set Address(Y Address)
        wr_cmd(0xc0);//Set Display Start Line(Z Address)
}

void wr_dots(uchar dat1,uchar dat2)
{
        uint page_cnt,col_cnt;
        uchar pg_address;
        pg_address = 0xb8;
        for (page_cnt=0;page_cnt<8;page_cnt++)
        {
                wr_cmd(pg_address); //Set Page Address(X Address)
                wr_cmd(0x40);//Set Address(Y Address)
                for (col_cnt=0;col_cnt<32;col_cnt++)
                {
                        wr_dat(dat1);
                        wr_dat(dat2);
                }

                pg_address ++;
        }
}

#pragma disable
void wr_border(void)
{
        uint page_cnt,col_cnt;
        uchar pg_address;
        pg_address = 0xb8;
        for (page_cnt=0;page_cnt<8;page_cnt++)
        {
                wr_cmd(pg_address); //Set Page Address(X Address)       
                wr_cmd(0X40);//Set Address(Y Address)
                wr_dat(0xff);
               
                for (col_cnt=1;col_cnt<63;col_cnt++)
                {
                        wr_dat(border_inf[page_cnt]);
                }
                wr_dat(0xff);
                pg_address ++;
        }
}

#pragma disable
void disp_dat(uchar dat1,uchar dat2)
{
        CS1=1;CS2=0;
        wr_dots(dat1,dat2);
        CS1=0;CS2=1;
        wr_dots(dat1,dat2);

}

#pragma disable
void disp_border(void)
{
        CS1=1;CS2=0;
        wr_border();
        CS1=0;CS2=1;
        wr_border();
       
}

#pragma disable
void disp_bmp(uchar_code *bmparea)
{
  uint i=0,j=0;
  uchar temp;
  CS1=1;CS2=0;
  temp=0xb8;
  wr_cmd(0xc0);
  for(j=0;j<8;j++)
  {
    wr_cmd(temp);
    wr_cmd(0x40);
    for(i=0;i<64;i++)
    { wr_dat(bmparea[i+j*128]);}
    temp++;
  }

  CS1=0;CS2=1;
  temp=0xb8;
  wr_cmd(0xc0);
  for(j=0;j<8;j++)
  {
    wr_cmd(temp);
    wr_cmd(0x40);
    for(i=0;i<64;i++)
    { wr_dat(bmparea[i+j*128+64]);}
    temp++;
  }

}


void main()
{
       
        RST=0;
        delays(10);
        RST=1;
        delays(5);
       
        //S6B0108 initial
        initial();

        while (1)
        {
                disp_dat(0xff,0xff); //All Dots Display
                delays(100);
                disp_dat(0x00,0x00); //Clear Screen
                delays(100);
                disp_dat(0xaa,0xaa); //Seperate rows I
                delays(100);
                disp_dat(0x55,0x55); //Seperate rows II
                delays(100);
                disp_dat(0xff,0x00); //Seperate Columns I
                delays(100);
                disp_dat(0x00,0xff); //Seperate Columns II
                delays(100);
                disp_dat(0xaa,0x55); //Seperate Dots I
                delays(100);
                disp_dat(0x55,0xaa); //Separate Dots II
                delays(100);
                disp_border();//Display The Border
                delays(100);
                disp_bmp(bmp_area);
                delays(100);
               
        }
}

使用特权

评论回复
8
jack_shine| | 2011-6-12 18:45 | 只看该作者
管脚之间没有影响的,都是独立位寄存器控制的

使用特权

评论回复
9
NE5532| | 2011-6-12 18:49 | 只看该作者
拿什么测的?怎么判断的?

使用特权

评论回复
10
sunningning|  楼主 | 2011-6-12 19:29 | 只看该作者
拿万用表测的:L,给端口赋值,然后测

使用特权

评论回复
11
NE5532| | 2011-6-12 19:57 | 只看该作者
测到什么结果?

使用特权

评论回复
12
liyeting2012| | 2011-6-12 20:08 | 只看该作者
单片机管脚之间内部没有影响的,在外部的12864的外围电路的影响。

使用特权

评论回复
13
NE5532| | 2011-6-12 20:14 | 只看该作者
单片机管脚之间内部没有影响的,在外部的12864的外围电路的影响。
liyeting2012 发表于 2011-6-12 20:08


不见得,这个结论违反哲学的基本原理——矛盾的普遍性。管教间相互影响的时候偶还真遇到过,不过是高级问题,在这里不讨论了。

使用特权

评论回复
14
enjier| | 2011-6-13 08:45 | 只看该作者
单片机引脚之间肯定是没有影响的,可能你的程序中出了一点儿问题,好好查查程序,说不一定能查出什么端倪来.......

使用特权

评论回复
15
救火车| | 2011-6-13 18:31 | 只看该作者
奇怪的问题往往是低级错误。请楼主检查各芯片的电源和地。先排除缺电源、缺地 的可能。
然后检查程序。重建一个空程序,什么都不写。如果故障消失,在继续检查程序。

使用特权

评论回复
16
jack_shine| | 2011-6-13 21:33 | 只看该作者
顶ls的说法

使用特权

评论回复
17
seawaveqq| | 2011-6-18 11:28 | 只看该作者
可能程序有问题,造成液晶反过影响了单片机吧。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

12

帖子

1

粉丝