標(biāo)題: 倆個單片機發(fā)送問題的程序 [打印本頁]

作者: 不會玩    時間: 2015-5-16 16:40
標(biāo)題: 倆個單片機發(fā)送問題的程序
關(guān)于倆個單片機發(fā)送問題的程序
#include<reg51.h>
#define uchar unsigned char
char code map[]={0x3f,0x06,0x5b,0x4f,0x66,0x7d,0x07,0x7f,0x6f};
void delay(unsigned int time)
{
unsigned int j=0;
for(;time>0;time--)
  for(j=0;j<125;j++);
}
void main(){
uchar counter=0;
TMOD=0x20;
TH1=TL1=0xf4;
PCON=0;
SCON=0x50;
TI=1;
while(1)
{SBUF=counter;
while(TI==0);
TI=0;
while(RI==0);
RI=0;
if(SBUF==counter)
{P2=map[counter];
if(++counter>9)counter=0;
delay(500);
}
}
}這是第一個單片機的

下面第二個的
#include<reg51.h>
#define uchar unsigned char
char code map[]={0x3f,0x06,0x5b,0x4f,0x66,0x7d,0x07,0x7f,0x6f};
void main()
{
  uchar receive;
  TMOD=0x20;
  TH1=TL1=0xf4;
  PCON=0;
  SCON=0x50;
  TR1=1;
  while(1){
   while(RI==1){
   RI=0;
   receive=SBUF;
   SBUF=receive;
   while(TI==0);
   TI=0;
   P2=map[receive];
   }
   }
   }為什么顯示的是圖上的東西 不會自己跳轉(zhuǎn)

QQ截圖20150516163446.png (23.47 KB, 下載次數(shù): 157)

QQ截圖20150516163446.png





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1