?? 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 + -