本帖最后由 胡斯哲 于 2013-1-1 15:26 编辑
我用的12m晶振 芯片为STC12c5a60s2 自己参照网上写的程序如下(问题很多):
#include <reg52.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit k1=P2^5;
uchar code table[]="wlllllllllllllllllllll";
uchar i;
void delay(int x)
{
uchar j;
while(x--)
{
for(j=0;j<120;j++);
}
}
void mian()
{
SCON = 0x50;
TMOD = 0x20;
PCON = 0x00;
TH1 = 0xf3;
TL1 = 0xf3;
TR1 = 1;
IE = 0x00;
while(1)
{
if(k1==0)
{
i=0;
delay(100); //消抖
while(table!='\0')
{
SBUF = table;
while(!TI);
TI = 0;
i++;
}
}
}
}
但用stc-isp的串口调试助手结果如图结果总是乱码,还有就是那个字符串有大于22位(不算'|0')时,串口调试助手的接收区才会有反应: |