STC15F2K60S2串口2程序
#include "reg51.h"
sfr P4 = 0xc0;
sfr P5 = 0xc8;
sfr AUXR = 0x8e ;
sfr S2CON = 0x9a ;
sfr S2BUF = 0x9b ;
sfr T2H
sfr T2L
sfr IE2
sfr IP2
#define S2RI 0x01
#define S2TI 0x02
unsigned char temp ;
bit
unsigned char xdata Uart1TxBuffer [20] = "杜兴杰你必须加油个"; //
void Uart2Init(void) //9600bps@11.0592MHz
{
S2CON = 0x50; //8位数据,可变波特率
AUXR |= 0x04; //定时器2时钟为Fosc,即1T
T2L = 0xE0; //设定定时初值
T2H = 0xFE; //设定定时初值
AUXR |= 0x14; //启动定时器2
EA = 1 ;
IE2 = 0x01 ;
IP2 |= 0x00 ;
}
void main( void )
char i ;
P0 = 0 ;
Uart2Init() ;
SendData (C) ;
SendData (C) ;
for ( i = 0 ; i < 20 ; i++ )
}
for ( i = 0 ; i < 20 ; i++ )
}
SendData (C) ;
SendData (C) ;
while(1)
}
}
}
void Uart2( void ) interrupt 8
if( S2CON & S2RI )
}
}
}
//
下一步是把串口1和串口2 加在一起,还有就是加入循环队列实现流控等
STC15F2K60S2串口 相关文章:
- STC15F2K60S2串口1程序(11-26)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)