📄 test.c~
字号:
#include <mega16.h>
#include <delay.h>
void Setup(void);
void Communication(void);
void main()
{
Setup();
Communication();
while (1)
{
delay_ms(1000);
PORTA.0 = 0;
delay_ms(1000);
}
}
void Communication(void)
{
char x;
while(1)
{
while(UCSRA.7 == 0);
x = UDR; // get recieved charater x
while(UCSRA.5 == 0);
UDR = x; //transmiit x
// UDR: common I/O address of USART for recieving and transmitting Page 151
}
}
void Setup(void)
{
// serial output
UCSRA = 0b00000000; // not double speed
UCSRB = 0b00011000; // enable Rx, Tx
UCSRC = 0b10000011; // no parity, 1 stop, 8 data bit
UBRRH = 0;
UBRRL = 12;// 38400 bps
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -