任何人都可以显示一些示例代码或链接来帮助我解决这个问题。我想使用终端接收和传输字符串。
到目前为止,我只得到了这个-->
void usart_init(void)
{
UBRRH = 0x00;
UBRRL = 95;
UCSRB = (1 << RXEN) | (1 << TXEN) | **(1<<RXCIE)**;
UCSRC = (1<<URSEL)|(1<<USBS)|(3<<UCSZ0)|(1 << UCSZ1);
}
ISR (USART_RXC_vect)
{
PORTD= 0b00000100; //enable RTS
char ReceivedByte ;
ReceivedByte = UDR ; // Fetch the received byte value into the variable " ByteReceived "
UDR = ReceivedByte ; // Echo back the received byte back to the computer
PORTD= 0b00000000; //disable RTS
}
int main (void)
{
usart_init();
while(1)
{
sei();
}
return 0;
}
但这只能发送和接收一个字符。如何修改此代码以使其能够发送和传输字符串。
感谢您的帮助:)