#include <iom8V.h> unsigned char temp;
//主函數(shù) void main(void) { DDRD=0xff; //設置D口為推挽1輸出 PORTD=0x00; OSCCAL=0xaa; //校正內部RC振蕩器頻率,不同的芯片參數(shù)有差異 UCSRB=0x18; //RXD.TXD使能 UBRR=51; //9600bps,8.0M UCSRC=0X86; //8位數(shù)據(jù),1位停止位,無校驗 while(1) { while(!(UCSRA&0x80)); //等待接收完成 temp=UDR; //接收數(shù)據(jù) PORTD=temp; while(!(UCSRA&0x20)); //等待移位寄存器空 UDR=temp; //發(fā)送數(shù)據(jù) } }
[此貼子已經(jīng)被admin于2008-8-30 0:26:43編輯過]
|