本帖最后由 一个用户名 于 2021-6-10 00:34 编辑
这是程序问题还是电路问题啊,求分析
甲机源码:
#include <reg51.h>
void main()
{
unsigned char i;
unsigned char send[]={9,3,5,4,6,7};
TMOD=0x20;
TL1=0xf4;
TH1=0xf4;
TR1=1;
SCON=0x40;
for(i=0;i<6;i++)
{
SBUF=send[ i];
while(TI==0);
TI=0;
}
while(1);
}
乙机源码:
- #include <reg51.h>
- unsigned char code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
- unsigned char buffer[]={0x00,0x00,0x00,0x00,0x00,0x00};
- void disp(void);
- void main()
- {
- unsigned char i;
- TMOD=0x20;
- TL1=0xf4;
- TH1=0xf4;
- TR1=1;
- SCON=0x40;
- REN=1;
- for(i=0;i<6;i++)
- {
- while(RI==0);
- buffer[i]=SBUF;
- RI=0;
- }
- for(;;) disp();
- }
- void disp()
- {
- unsigned char w,i,j;
- w=0x01;
- for(i=0;i<6;i++)
- {
- P1=tab[buffer[i]];
- P2=~w;
- for(j=0;j<100;j++);
- w<<=1;
- }
- }
复制代码
|