资源简介
韦根26与串口通讯程序,是门禁及停车场行业开发程序必备的知识
代码片段和文件信息
#include
unsigned char CurrentData[4];
void Send_Char(unsigned char);
void Send_Data(void);
void main (void)
{
SCON = 0x50;
TMOD = 0x21;
EA=1;
ET0=1;
EX0=1;
EX1=1;
TH0 = 0xEE;
TL0 = 0x0;
TH1 = 0xFD;
TL1 = 0xFD;
TCON = 0x55;
while(1)
{
if(Current == 26)
{
Current = 0;
EA = 0;
Send_Data();
EA = 1;
}
}
}
void Ex0(void) interrupt 0
{
Data[(25 - Current) / 8] &= ~(0x1 << ((25 - Current) % 8));
TH0 = 0xEE;
TL0 = 0x0;
Current++;
}
void Ex1(void) interrupt 2
{
Data[(25 - Current) / 8] |= 0x1 << ((25 - Current) % 8);
TH0 = 0xEE;
TL0 = 0x0;
Current++;
}
void Timer0(void) interrupt 1
{
TH0 = 0xEE;
TL0 = 0x0;
Current = 0;
}
void Send_Char(unsigned char buf)
{
SBUF = buf;
while(TI == 0);
TI = 0;
}
void Send_Data(void)
{
Send_Char(0x55);
Send_Char(Data[3]);
Send_Char(Data[2]);
Send_Char(Data[1]);
Send_Char(Data[0]);
Send_Char(0xAA);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1331 2009-04-11 15:28 wg26_rs232.c
文件 813 2009-04-11 15:28 WG26_RS232.hex
文件 4260 2009-04-11 15:28 WG26_RS232
----------- --------- ---------- ----- ----
6404 3
- 上一篇:ROS中smartcar机器人的描述文件
- 下一篇:pointCloud
评论
共有 条评论