📄 uart.c.bak
字号:
/*****************************************
串行口测试程序
输入数据:无
输出:程序复位后先向串口发送"Hellow Word!",之后没收到一个非0字符就向串口发送"OK!"
作者:蒋剑东
修改时间:2004-09-02
*****************************************/
#include "iom16.h"
#include "stdio.h"
#include "macros.h" // 常用的宏定义
#define uchar unsigned char
#define uint unsigned int
//----------------------- 延时函数 START -------------------------
/*****************************************
延时n毫秒,不是很精确
晶振8M
作者:蒋剑东
修改时间:2004-09-03
*****************************************/
void delay_nms(uint count)
{
uint i,j;
for( j=1;j<=count;j++ )
{
for( i=0;i<830;i++ )
{
asm("wdr");
}
}
}
//----------------------- 延时函数 END -------------------------
void cpu_init(void)
{
// 串行口初始化 START
UBRR = 0x33; // 波特率9600
UCR = 0x18;
//UCSRA = 0x00;
//UCSRC = 0x86;
// I/O口初始化
PORTB = 0xff;
DDRB = 0xff;
// AD初始化
}
void main(void)
{
uchar temp;
cpu_init();
puts("Hellow Word!");
while(1)
{
/*while(!(USR&0x80));
UDR=UDR;
while(!(USR&0X40));
USR|0x40;*/
PORTB ^= (1<<3);
delay_nms(1000);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -