2014-11-27 13 views
1

ATmega128 (UART)에 대한 질문이 있습니다 이 프로그램은 UART를 통해 Hello 메시지를 보냅니다.ATmega128 - UCSROA 미표시 (이 함수에서 처음 사용)

다음은 제 코드입니다.

#include <avr/io.h> 

void putch(unsigned char data) 
{ 
    while((UCSROA & 0x20) == 0); 
    UDR0 = data; 
    UCSROA |= 0x20; 
} 

int main() 
{ 
    unsigned char text[] = "Hello! World!\r\n"; 
    unsigned char i = 0; 

    DDRE = 0xFE; 
    UCSROA = 0x00; 
    UCSROB = 0x18; 
    UCSROC = 0x06; 
    UBRROH = 0x00; 
    UBRROL = 0x03; 

    while(text[i] != '\0') 
    putch(text[i++]); 
    return 0; 

} 

이것은 오류 메시지입니다.

Build succeeded with 0 Warnings... 
avr-gcc -mmcu=atmega128 -Wall -gdwarf-2 -std=gnu99 -DF_CPU=7372800UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -MD -MP -MT Hello.o -MF dep/Hello.o.d -c ../Hello.c 
../Hello.c: In function 'putch': 
../Hello.c:5: error: 'UCSROA' undeclared (first use in this function) 
../Hello.c:5: error: (Each undeclared identifier is reported only once 
../Hello.c:5: error: for each function it appears in.) 
../Hello.c: In function 'main': 
../Hello.c:16: error: 'UCSROA' undeclared (first use in this function) 
../Hello.c:17: error: 'UCSROB' undeclared (first use in this function) 
../Hello.c:18: error: 'UCSROC' undeclared (first use in this function) 
../Hello.c:19: error: 'UBRROH' undeclared (first use in this function) 
../Hello.c:20: error: 'UBRROL' undeclared (first use in this function) 
make: *** [Hello.o] Error 1 Build failed with 8 errors and 0 warnings... 

다른 컴퓨터에서 테스트를 마쳤습니다.
하지만 작동하지 않습니다.
이 문제를 해결하는 방법을 모르겠습니다.

몇 가지 조언을 해주세요.
감사합니다.

답변

1

그것은하지

UCSR O 문자가있는

는 "O", 그것은 수 0

UCSR0A

입니다.

+0

다른 선언되지 않은 항목은 'O'대신 '0'을 사용합니다. – UncleO