打印
[AVR单片机]

2句程序,这么多错误

[复制链接]
2780|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
yuezhaoxu|  楼主 | 2007-3-9 00:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
IO, TI, vr, AVR, TE
程序如下:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/delay.h>
#include <stdio.h>

int main(void)
{DDRA=0XFF;
 PORTA=0XFF;
}
错误如下:
-------- begin --------
avr-gcc (GCC) 3.4.6
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Compiling: IO.c
avr-gcc -c -mmcu=atmega8 -I. -gdwarf-2 -DF_CPU=8000000UL  -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=IO.lst  -std=gnu99 -MD -MP -MF .dep/IO.o.d IO.c -o IO.o 
In file included from IO.c:4:
C:/WinAVR/avr/include/avr/signal.h:36:2: warning: #warning "This header file is obsolete.  Use <avr/interrupt.h>."
In file included from IO.c:5:
C:/WinAVR/avr/include/avr/delay.h:36:2: warning: #warning "This file has been moved to <util/delay.h>."
IO.c: In function `main':
IO.c:9: error: `DDRA' undeclared (first use in this function)
IO.c:9: error: (Each undeclared identifier is reported only once
IO.c:9: error: for each function it appears in.)
IO.c:10: error: `PORTA' undeclared (first use in this function)
IO.c:11:2: warning: no newline at end of file
make.exe: *** [IO.o] Error 1

> Process Exit Code: 2
> Time Taken: 00:0
makefile如下:

# MCU name
MCU = atmega8


# Processor frequency.
#     This will define a symbol, F_CPU, in all source code files equal to the 
#     processor frequency. You can then use this symbol in your source code to 
#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
#     automatically to create a 32-bit value in your source code.
F_CPU = 8000000


# Output format. (can be srec, ihex, binary)
FORMAT = ihex


# Target file name (without extension).
TARGET = IO


# List C source files here. (C dependencies are automatically generated.)
SRC = $(TARGET).c

相关帖子

沙发
hotpower| | 2007-3-9 01:37 | 只看该作者

头文件和尾没换行

使用特权

评论回复
板凳
zsmbj| | 2007-3-9 08:52 | 只看该作者

晕,M8有PORTA口吗?看看手册。

取消:#include <avr/signal.h>

delay改成:#include <util/delay.h>

使用特权

评论回复
地板
yuezhaoxu|  楼主 | 2007-3-9 11:23 | 只看该作者

谢谢

谢谢,的确是这样,我还以为软件有问题了呢?

使用特权

评论回复
5
yuezhaoxu|  楼主 | 2007-3-9 20:09 | 只看该作者

avr降低功耗小技巧

http://www.heima.com/web/Page0.srf?userid=1408330&columnno=3&rowid=0

使用特权

评论回复
6
一路向北lm| | 2018-7-2 21:58 | 只看该作者
yuezhaoxu 发表于 2007-3-9 11:23
谢谢,的确是这样,我还以为软件有问题了呢?

这都是些简单的问题,先参考下教程,这样入门比较快,少走弯路。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

28

主题

66

帖子

1

粉丝