資源簡介
串口試驗.c
代碼片段和文件信息
#include“stc12c5a60s2.h“
#include?“stdio.h“
#define?uchar?unsigned?char
#define?uint?unsigned?int
uchar?shu;
uchar?Command;
uchar?x=50;
uchar?y=40;
uchar?j;
?
?char?cmd[128]={0};
?uchar?pstr2[6]={‘0‘};
bit B_TI;
void?UartInit(void) //115200bps@24.000MHz
{
AUXR?|=?0x08; //
S2CON?=?0x50; //
AUXR?|=?0x04; //
BRT?=?0xF3;
AUXR?|=?0x10; //
}
void?daly(uint?i)
{
?while(i--);
}
void?TxByte(unsigned?char?dat)
{
B_TI?=?0;
S2BUF?=?dat;
while(!B_TI) ;
B_TI?=?0;
}
/**********************************************/
void PrintStrings(unsigned?char??*sts)
{
????for?(;?*sts?!=?0;?sts++) TxByte(*sts);
}
void??shijianxianshi(uchar?x?y?temptemp1)
{
??if(temp/10==0)
??pstr2[0]=‘?‘;
??else
??pstr2[0]=temp/10+‘0‘;
??pstr2[1]=temp%10+‘0‘;
?pstr2[3]=temp/10+‘0‘;
??pstr2[4]=temp%10+‘0‘;
?
?pstr2[2]=‘:‘;
??sprintf(cmd“DCV32(%2d%2d\‘%s\‘15);\r\n“(int)x(int)y(char?*)pstr2);
?? PrintStrings(cmd);
?
??
}
void??wenshiduxianshi(uchar?x?y?temptemp1bit?BB)
{
??if(temp/10==0)
??pstr2[0]=‘?‘;
??else
??pstr2[0]=temp/10+‘0‘;
?pstr2[1]=temp%10+‘0‘;
?pstr2[2]=‘.‘;
?pstr2[3]=temp/10+‘0‘;
??pstr2[4]=temp%10+‘0‘;
??sprintf(cmd“DCV16(%2d%2d\‘%s\‘23);\r\n“(int)x(int)y(char?*)pstr2);
?? PrintStrings(cmd);
???BB=0;
??
}
v
- 上一篇:IT員工個人周報模板
- 下一篇:C8051F410A/D轉(zhuǎn)換程序
評論
共有 條評論