51单片机模拟串口C语言程序代码
#include "string.h"
#include"stdio.h"
#include
sfr16
typedef unsigned char
typedef unsigned int
typedef unsigned char
typedef unsigned int
typedef unsigned int
typedef unsigned char
typedef unsigned int
#define YES
#define NO
//定义使用哪个定时器, 只可定义一个
#define TIMER_0
//#define TIMER_1
//定义串口收、发送管脚。
sbit rs_TXD = P2^1;
sbit rs_RXD = P2^0;
//根据定时器确定参数
#ifdef TIMER_0
#endif
#ifdef TIMER_1
#endif
INT8U
sbit
INT8U
INT8U
sbit
sbit
sbit
//选择以下一个晶体频率
//#define Fosc 6000000
#define Fosc 11059200
//#define Fosc 12000000
//#define Fosc 18432000
//#define Fosc 20000000
//#define Fosc 24000000
//#define Fosc 30000000
//#define Fosc 40000000
//选择以下一个波特率:
//#efine Baud 300
//#define Baud 1200
//#define Baud 2400
//#define Baud 4800
#define Baud 9600
//#define Baud 14400
//#define Baud 19200
//#define Baud 28800
//#define Baud 38400
//#define Baud 57600
//收、发一位所需定时器计数
#define rs_FULL_BIT0 ((Fosc/12) / Baud)
#define rs_FULL_BIT (65536 - rs_FULL_BIT0)
#define rs_FULL_BIT_H rs_FULL_BIT >> 8
#define rs_FULL_BIT_L (rs_FULL_BIT & 0x00FF)
//检测起始位的时间间隔所需定时器计数
#define rs_TEST0 rs_FULL_BIT0 / 4
#define rs_TEST ((~rs_TEST0))
#define rs_TEST_H rs_TEST >> 8
#define rs_TEST_L rs_TEST & 0x00FF
//发送起始位所需定时器总计数
#define rs_START_BIT 0xFFFF - (Fosc/12/Baud) + 0x28
#define rs_START_BIT_H rs_START_BIT >> 8
#define rs_START_BIT_L rs_START_BIT & 0x00FF
#define rs_RECEIVE_MAX
INT8U
INT16U
void soft_rs232_interrupt( void );
#ifdef TIMER_0
#endif
#ifdef TIMER_1
#endif
void soft_rs232_init (void)
{
}
void soft_receive_init()
{
51单片机模拟串口C语言程 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)