/*********************************************************/
/* */
/* 第2篇第8章 串口校准发送测试 源程序 */
/* */
/* 编写:江海波 */
/* */
/* 2007-03 V1.0 */
/* */
/* 提示 : 本程序仅随本书使用,保留版权 */
/* 实例代码用于工程时应谨慎! */
/* */
/* E-mail : soundman@sohu.com */
/* */
/*********************************************************/
#include "iom48v.h"
#include "macros.h"
void uart0_init(void)
{
UCSR0A = 0x02; //使用波特率倍增,不使用多从机模式
UCSR0C = 0x06; //异步串口模式,禁止奇偶校验,1位停止位,8-bit桢模式
UBRR0L = 0x0C; //设置波特率,9600
UBRR0H = 0x00;
UCSR0B = 0x98; //允许接收完成中断使能,禁止发送完成中断,禁止发送寄存器空中断,允许接收,允许发送
}
void Delay_ms(unsigned int Time)
{
unsigned char n=0;
while(Time>0)
{
for (n=1;n<187;n++)
{
NOP();
}
Time--;
}
}
void main (void)
{
unsigned char SendData = 0xFF;
uart0_init();
do
{
while(!(UCSR0A&(1<<UDRE0)));
UDR0 = SendData;
SendData--;
}
while(SendData != 0xFF);
while(1);
}
UART.rar_NEC_NEC uart_uart nec
版权申诉
54 浏览量
2022-09-19
14:35:40
上传
评论
收藏 9KB RAR 举报
朱moyimi
- 粉丝: 65
- 资源: 1万+