wanglequn 发表于 2010-8-7 22:33:32

请各位老师帮我看一下这个程序究竟错在哪里(附studio提示)

我的第一个程序,求大家帮一把。

#include "avr/iom16.h"
#include "interrput.h"

#define F_CPU 1000000
#define BAUD 9600
void USART_Transmit(void );
void ISR_TEST (void);

PORTA=0b00000000;
DDRA=0b11100111;
void main (void)
{
UBRRL=(F_CPU/BAUD/16-1)/256;
UBRRH=(F_CPU/BAUD/16-1)%256;/*初始化波特率低八位和高四位*/

UCSRB=((1<<RXCIE)|(1<<RXEN))|(1<<TXEN);/*置位接收中断使能位和接受、发送使能位*/
SREG=0X80;


}

/* 发送数据函数 */
void USART_Transmit(void)
{
/* 等待发送缓冲器为空 */
while ( !( UCSRA & (1<<UDRE)) );
/* 将数据放入缓冲器,发送数据 */
UDR = 0x55;
}

/* 接收数据中断处理函数*/


void ISR_TEST (void)//串口接收中断服务程序

{
PC_COMMAND=UDR;
switch(PC_COMMAND)
{
case '0': //0x30 ASCII '0'
PORTA=0B00000001;
break;
case '1':
PORTA=0B00000011;
break;
case '2':
PORTA=0B00000111;
break;
case '3':
PORTA=0B00001111;
break;
case '4':
PORTA=0B00011111;
break;
case '5':
PORTA=0B00111111;
break;
case '6':
PORTA=0B01111111;
break;
case '7':
PORTA=0B11111111;
break;

}
}
下面是studio的提示:
Build started 7.8.2010 at 22:19:04
In file included from ../chuankou.c:1:
d:/winavr-20100110/lib/gcc/../../avr/include/avr/iom16.h:41:4: error: #error "Include <avr/io.h> instead of this file."
../chuankou.c:4:1: warning: "F_CPU" redefined
<command-line>: warning: this is the location of the previous definition
../chuankou.c:6: error: stray '\243' in program
../chuankou.c:6: error: stray '\273' in program
../chuankou.c: In function 'USART_Transmit':
../chuankou.c:9: error: expected declaration specifiers before '(' token
../chuankou.c:10: error: expected declaration specifiers before '(' token
../chuankou.c:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
../chuankou.c:24: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
../chuankou.c:36: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
../chuankou.c:67: error: old-style parameter declarations in prototyped function definition
../chuankou.c:66: error: expected '{' at end of input
make: *** Error 1
Build failed with 10 errors and 2 warnings...
页: [1]
查看完整版本: 请各位老师帮我看一下这个程序究竟错在哪里(附studio提示)