本帖最后由 anthonyxoxo 于 2013-7-4 15:51 编辑
在线等。
先贴代码:#define F_CPU 7372800
//#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#define BAUD 9600
unsigned char transmit;
void Port_init(void);
void Usart_init(void);
void Usart_Putchar(unsigned char);
int main(void)
{
Port_init();
Usart_init();
transmit = 0x55;
Usart_Putchar(transmit);
sei();
while(1)
{
}
}
void Port_init(void)
{
PORTE = 0x00;
DDRE = 0xfe;
}
void Usart_init(void)
{
UCSR0A = 0x00;
UCSR0C |= (1<<UMSEL0) | (1<<UCSZ01) | (1<<UCSZ00);
UBRR0L = (F_CPU / BAUD / 16 - 1) % 256;
UBRR0H = (F_CPU / BAUD / 16 - 1) / 256;
UCSR0B |= (1<<TXEN);
}
void Usart_Putchar(unsigned char cTXData)
{
while(!(UCSR0A & (1<<UDRE)));
UDR0 = cTXData;
}
为啥收回来的都是0xff?
明天老师要检查,求助各位大神~ |