我试图在TERA TERM模拟器上显示A,但是当我在ATMEL STUDIO 7上运行代码时,代码不会停止运行。
这是我下面的代码,我正在atmel studio 7上的模拟器工具上运行程序,我相信我正确配置了UART
#include <avr/io.h>
void configureUART(void);
void sendUART(unsigned char);
int main(void)
{
configureUART();
sendUART('A');
}
void sendUART(unsigned char transmitByte)
{
while ((UCSRA & (1 << UDRE))== 0);
// Data register is ready, transmit out the byte.
UDR = transmitByte;
}
void configureUART()
{
//Baud Rate Config 9600 => 0x4D
UBRRH = 0x00;
UBRRL = 0x4D;
//Need to use UCSRC Register w/ asynchronous op. and 1 stop bit w/ 8 data bits
UCSRC = (1 << URSEL) | (0 << USBS) | (1 << UCSZ0) | (1 << UCSZ0) ;
//Transmit and Receive
UCSRB = (1 << RXEN) | (1 << TXEN);
}