📄 uart_main._c
字号:
//UART试验主机程序
#include <iom16v.h>
#include <macros.h>
#include "uart1.h"
#define uint unsigned int
ms(uint aa)
{
for(;aa>0;aa--);
}
main()
{
uchar i=0,rx_temp;
init_devices(); //初始化
DDRD=0xff;
PORTD=0x00;
ms(60000);
while(1)
{
uart_tx(i); //发送数据i
rx_temp=rx_c(); //查询接收
if(rx_temp==i) //验证发送接收是否正确
{
i++;
PORTD=~i<<2;
ms(60000);
ms(60000);
ms(60000);
ms(60000);
ms(60000);
}
else //通信错误
{
while(1)
{
PORTD=0x00;
ms(60000);
ms(60000);
ms(60000);
PORTD=0xff;
ms(60000);
ms(60000);
ms(60000);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -