搜索
bottom↓
回复: 0

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

[复制链接]

出0入0汤圆

发表于 2010-8-7 22:33:32 | 显示全部楼层 |阅读模式
我的第一个程序,求大家帮一把。

#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: *** [chuankou.o] Error 1
Build failed with 10 errors and 2 warnings...
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-4-29 08:07

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表