单片机控制的上位机软件怎么做?用什么软件做?
2个回答
展开全部
串口中断,调用一些《stdio.h>中的库函数就行了 软件用 串口调试助手
#include<reg52.h>
#include<stdio.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={
0x7f,0xbf,0xdf,0xef,
0xf7,0xfb,0xfd,0xfe
};
uchar code tabled[]={
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90};
void delay(uint a)
{
uint i,j;
for(j=a;j>0;j--)
for(i=110;i>0;i--);
}
uchar flag,aa,flag1,flag2;
void init()
{
TMOD=0x21;
TH1=0xfd;
TL1=0xfd;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR1=1;
SM1=1;
SM0=0;
REN=1;
EA=1;
ES=1;
ET0=1;
}
void main()
{
uchar i;
init();
while(1)
{
if(flag==1)
{
if(flag1==0)
{
ES=0;
TI=1;
puts("success or not?!\n");
while(!TI);
TI=0;
ES=1;
flag1=1;
}
if(flag2==0)
{
for(i=0;i<8;i++)
{
P2=table[i];
P0=tabled[i+1];
delay(1);
}
}
if(flag2==1)
{
P0=0xff;
P2=0xff;
}
}
if(flag==0)
{
P1=0xaa;
delay(500);
P1=~0xaa;
delay(500);
}
}
}
void ser() interrupt 4
{
RI=0;
flag=1;
flag1=0;
flag2=0;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
}
void T0_time() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==100)
{
aa=0;
flag2=1;
TR0=0;
}
}
我以前做的,IO口你就忽视吧
#include<reg52.h>
#include<stdio.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={
0x7f,0xbf,0xdf,0xef,
0xf7,0xfb,0xfd,0xfe
};
uchar code tabled[]={
0xc0,0xf9,0xa4,0xb0,
0x99,0x92,0x82,0xf8,
0x80,0x90};
void delay(uint a)
{
uint i,j;
for(j=a;j>0;j--)
for(i=110;i>0;i--);
}
uchar flag,aa,flag1,flag2;
void init()
{
TMOD=0x21;
TH1=0xfd;
TL1=0xfd;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR1=1;
SM1=1;
SM0=0;
REN=1;
EA=1;
ES=1;
ET0=1;
}
void main()
{
uchar i;
init();
while(1)
{
if(flag==1)
{
if(flag1==0)
{
ES=0;
TI=1;
puts("success or not?!\n");
while(!TI);
TI=0;
ES=1;
flag1=1;
}
if(flag2==0)
{
for(i=0;i<8;i++)
{
P2=table[i];
P0=tabled[i+1];
delay(1);
}
}
if(flag2==1)
{
P0=0xff;
P2=0xff;
}
}
if(flag==0)
{
P1=0xaa;
delay(500);
P1=~0xaa;
delay(500);
}
}
}
void ser() interrupt 4
{
RI=0;
flag=1;
flag1=0;
flag2=0;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
TR0=1;
}
void T0_time() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==100)
{
aa=0;
flag2=1;
TR0=0;
}
}
我以前做的,IO口你就忽视吧
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询