/*********************************************
File name : USART.c
Chip type : ATmega16
Program type : Application
Clock frequency : 4.000000 MHz
Memory model : Small
External SRAM size : 0
Data Stack size : 256
*********************************************/
#include <mega16.h>
#include <delay.h>
#define BAUD 1200 // 波特率采用1200bps
#define CRYSTAL 4000000 // 系统时钟4MHz
//计算和定义波特率设置参数
#define BAUD_SETTING (unsigned int)((unsigned long)CRYSTAL/(16*(unsigned long)BAUD)-1) // 波特率计算
#define BAUD_H (unsigned char)(BAUD_SETTING>>8) // 高8位
#define BAUD_L (unsigned char)(BAUD_SETT