454234682 发表于 2012-10-5 10:07:02

救急啊!!!

本帖最后由 454234682 于 2012-10-5 10:38 编辑

我用AVR-GCC编译程序,老是出现这个问题,解决不了哇,在线等!!!!!谢谢大侠


老是出现\M16-GCC例程\lcd12864/main.c:16: undefined reference to `LCD_Init'
可是我已将包含了#include "lcd12864.h"

下面lcd12864.h文件
#ifndef _LCD12864_H_
#define _LCD12864_H_

#include <avr/io.h>
#define LCD12864_CSPORTA=(1<<7)
#define LCD12864_SID PORTA=(1<<6)
#define LCD12864_SCK PORTA=(1<<5)

#define uchar unsigned char
#define uint unsigned int

void LCD_Init(void);//液晶初始化
uchar LCD_ReceiveByte(void);
void LCD_CheckBusy(void);//判断液晶是否忙
void LCD_WriteCommand(uchar Cbyte);//写指令
void LCD_WriteData(uchar Dbyte);//写数据
uchar LCD_ReadData(void);

void LCD_DisplayChinese(uchar Addr,uchar *p);//显示中文或字符串
void LCD_DisplayNumber(uchar Addr,int num);//显示数字
void LCD_DisplayCLR(void);          //(开机消除噪点)

#endif


难道是Makfile没有包含.C文件?有人知道怎么弄嘛?
这样写对不对啊?
# Target file name (without extension).
TARGET = main


# Object files directory
#   To put object files in current directory, use a dot (.), do NOT make
#   this an empty or blank macro!
OBJDIR = .


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


# List Assembler source files here.
#   Make them always end in a capital .S.Files ending in a lowercase .s
#   will not be considered source files but generated files (assembler
#   output from the compiler), and will be deleted upon "make clean"!
#   Even though the DOS/Win* filesystem matches both .s and .S the same,
#   it will preserve the spelling of the filenames, and gcc itself does
#   care about how the name is spelled on its command-line.
ASRC =


# Optimization level, can be .

trave_yang 发表于 2012-10-5 10:14:29

加个extern试试

tarzar 发表于 2012-10-5 10:17:26

建义直接把整个工程上传(当然了,可以把一些认为是重要文件去掉

454234682 发表于 2012-10-5 10:24:13

加个extern试试
加过也试过,不行啊

.titrwh 发表于 2012-10-5 10:24:36

不要用中文路径                                                                                                                                       

454234682 发表于 2012-10-5 10:24:56

我是新手,不知道这里对不对
#define LCD12864_CSPORTA=(1<<7)
#define LCD12864_SID PORTA=(1<<6)
#define LCD12864_SCK PORTA=(1<<5)

lcw_swust 发表于 2012-10-5 10:32:44

在main.c里写个#include "LCD12864.C"试试

454234682 发表于 2012-10-5 10:33:33

lcw_swust 发表于 2012-10-5 10:32 static/image/common/back.gif
在main.c里写个#include "LCD12864.C"试试

好的,我试试

454234682 发表于 2012-10-5 10:34:03

trave_yang 发表于 2012-10-5 10:14 static/image/common/back.gif
加个extern试试

加过也试过,不行啊

454234682 发表于 2012-10-5 10:34:27

.titrwh 发表于 2012-10-5 10:24 static/image/common/back.gif
不要用中文路径                                                                                       ...

好的,马上试试

yklstudent 发表于 2012-10-5 11:12:14

文件名换小写的,大写的会有问题

lngdzph 发表于 2012-10-5 13:26:20

454234682 发表于 2012-10-5 10:24 static/image/common/back.gif
我是新手,不知道这里对不对
#define LCD12864_CSPORTA=(1

应改成PORTA|=(1<<7);
不然按你的操作,每操作一个引脚会置零另外的引脚。
如果你想让avr的引脚输出高低电平,应该这样定义
#define LCD1286_CS_1 PORTA|=(1<<PA7);
#define LCD1286_CS_0 PORTA&=~(1<<PA7)‘

lngdzph 发表于 2012-10-5 13:30:29

把H文件改成小写.h试试,还有Makefile里
SRC = $(TARGET).c
SRC = lcd12864.c
改成SRC = $(TARGET).c lcd12864.c
或者
SRC = $(TARGET).c
SRC+ = lcd12864.c
页: [1]
查看完整版本: 救急啊!!!