音影先锋亚洲天堂网|电影世界尽头的爱完整版播放|国产 熟女 91|高清无码免费观看欧美日韩|韩国一区二区三区黄色录像|美女亚洲加勒比在线|亚洲综合网 开心五月|7x成人在线入口|成人网站免费日韩毛片区|国产黄片?一级?二级?三级

登錄 免費注冊 首頁 | 行業(yè)黑名單 | 幫助
維庫電子市場網(wǎng)
技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng)
驅(qū)動編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機 | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計 | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe

WinAVR環(huán)境下,多個C文件連接編譯請教。。!

作者:good_ys 欄目:單片機
WinAVR環(huán)境下,多個C文件連接編譯請教!!!
 用WinAVR軟件做ATMEGA162單片機開發(fā),在PN中新建了一個工程,其中添加了6個C文件及兩個頭文件。怎樣才能使這六個C文件連接起來一起編譯后生成一個HEX文件呢??
  吳雙力等編著的《AVR-GCC與AVR單片機C語言開發(fā)》書中說,該功能還不完善。不知大家是怎么做的??希望各位能賜教小弟,怎么才能解決這個問題。。。。ㄈ绻靡粋C文件來編寫程序,感覺不好管理,程序太大。)

2樓: >>參與討論
zsmbj
在makefile里將其他的文件名稱加入即可。
 
3樓: >>參與討論
zj4068
請看實例
下面是我根據(jù)它的makefile的基礎(chǔ)上改的,請看注釋


# Hey Emacs, this is a -*- makefile -*-
#
# WinAVR SAMPLE makefile written by Eric B. Weddington, J鰎g Wunsch, et al.
# Released to the Public Domain
# Please read the make user manual!
#
# Additional material for this makefile was submitted by:
#  Tim Henigan
#  Peter Fleury
#  Reiner Patommel
#  Sander Pool
#  Frederik Rouleau
#  Markus Pfaff
#
# On command LINE:
#
# make all = Make SOFTWARE.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
#
# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
#                4.07 or greater).
#
# make program = Download the hex file to the DEVICE, using avrdude.  Please
#                customize the avrdude settings below first!
#
# make fileNAME.s = Just compile fileNAME.c into the assembler code ONLY
#
# To rebuild project do "make clean" then "make all".

我這邊做了幾個目錄SRC目錄是放源程序的,我放的是*.c文件
INC目錄是放頭文件的,我放的是*.c文件

#add SRCDIR = SRC &  INCDIR = INC added by tomzhang 2004.10.21

SRCDIR = SRC
INCDIR = INC


CDEF和CDEF1是兩個預(yù)編譯項
#add CDEF = ADCEN & CDEF1 = TEST added by tomzhang 2004.10.21
#CDEF & CDEF1 is pre-compile macro

CDEF  = ADCEN
CDEF1 = TEST

# MCU NAME
MCU = ATMEGA8

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

# Target file NAME (without extension).
TARGET = main

#add $(SRCDIR) added by tomzhang 2004.10.21
#point out SRC directory

指出我的主文件是SRC目錄下的$(target).c
我這邊實際項目中是main.c
# List C source files here. (C dependencies are automatically generated.)
SRC = $(SRCDIR)/$(TARGET).c


# 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 [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s

# Debugging format.
# Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
DEBUG = stabs

# List any extra directories to look for include files here.
#     Each directory must be seperated by a space.
EXTRAINCDIRS =


# Compiler flag to set the C STANDARD level.
# c89   - "ANSI" C
# gnu89 - c89 plus GCC extensions
# c99   - ISO C99 STANDARD (not yet fully implemented)
# gnu99 - c99 plus GCC extensions
CSTANDARD = -std=gnu99


#add -D$(CDEF) #-D$(CDEF1) added by tomzhang 2004.10.21
#if have more pre-compile pls place here

# Place -D or -U options here

加入預(yù)編譯項
CDEFS = -D$(CDEF) -D$(CDEF1)

#add -I$(INCDIR) added by tomzhang 2004.10.21
#point out INC directory

-I指出我的*.h放在INC目錄
# Place -I options here
CINCS = -I$(INCDIR)


# Compiler flags.
#  -g*:          generate debugging information
#  -O*:          optimization level
#  -f...:        tuning, see GCC manual and avr-libc documentation
#  -Wall...:     warning level
#  -Wa,...:      tell GCC to pass this to the assembler.
#    -adhlns...: create assembler listing
CFLAGS = -g$(DEBUG)
CFLAGS += $(CDEFS) $(CINCS)
CFLAGS += -O$(OPT)
CFLAGS += -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -Wall -Wstrict-prototypes
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
CFLAGS += $(CSTANDARD)



# Assembler flags.
#  -Wa,...:   tell GCC to pass this to the assembler.
#  -ahlms:    create listing
#  -gstabs:   have the assembler create LINE NUMBER information; note that
#             for use in COFF files, additional information about fileNAMEs
#             and function NAMEs needs to be present in the assembler source
#             files -- see avr-libc docs [FIXME: not yet described there]
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs



#Additional libraries.

# Minimalistic printf version
PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min

# Floating point printf version (requires MATH_LIB = -lm below)
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt

PRINTF_LIB =

# Minimalistic scanf version
SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min

# Floating point + %[ scanf version (requires MATH_LIB = -lm below)
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt

SCANF_LIB =

MATH_LIB = -lm

# External MEMORY options

# 64 KB of external RAM, starting after internal RAM (ATMEGA128!),
# used for variables (.data/.bss) and heap (malloc()).
#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff

# 64 KB of external RAM, starting after internal RAM (ATMEGA128!),
# ONLY used for heap (malloc()).
#EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff

EXTMEMOPTS =

# Linker flags.
#  -Wl,...:     tell GCC to pass this to linker.
#    -Map:      create map file
#    --cref:    add cross reference to  map file
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += $(EXTMEMOPTS)
LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)




# PROGRAMMING SUPPORT using avrdude. Settings and variables.

# PROGRAMMING HARDWARE: alf avr910 AVRISP bascom bsd
# dt006 pavr picoweb pony-stk200 SP12 stk200 STK500
#
# Type: avrdude -c ?
# to get a full listing.
#
AVRDUDE_PROGRAMMER = STK500

# com1 = serial port. Use lpt1 to connect to parallel port.
AVRDUDE_PORT = com1    # programmer connected to serial DEVICE

AVRDUDE_WRITE_FLASH = -U FLASH:w:$(TARGET).hex
#AVRDUDE_WRITE_EEPROM = -U EEPROM:w:$(TARGET).eep


# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.
#AVRDUDE_ERASE_COUNTER = -y

# Uncomment the following if you do /not/ wish a verification to be
# performed after PROGRAMMING the DEVICE.
#AVRDUDE_NO_VERIFY = -V

# Increase verbosity level.  Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AV
4樓: >>參與討論
zj4068
有一處INC存放的應(yīng)是*.h文件
  有一處INC存放的應(yīng)是*.h文件,錯寫成*.c文件,請見諒。
  最后一處我的意思是說我那個模板程序不知道如何上傳到這邊來,如有人想要,請發(fā)我郵箱聯(lián)系。

5樓: >>參與討論
good_ys
非常感謝zj4068兄。。!
  辛苦了!我不知道你Mail地址。能把你做的文件及資料發(fā)到我郵箱嗎??萬分感謝!!
  E_mail:good_ys@163.com
  QQ:11359214

6樓: >>參與討論
hotpower
沒有如此復(fù)雜...
#兩個文件i2c.c和numled.c,只需在SRC = $(TARGET).c后加" numled.c"即可...

#例:
# OUTPUT format. (can be srec, ihex, binary)
FORMAT = ihex

# Target file NAME (without extension).
TARGET = i2c


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


7樓: >>參與討論
abc2001
看看就明白了


# List C source files here. (C dependencies are automatically generated.)
SRC = $(TARGET).c  at24c512.c comm.c Ht1302.c Ic.c Init.c Msk2368.c Pocsag.c timerInt.c uart.c

8樓: >>參與討論
good_ys
謝謝hotpower&&abc2001!!
 繼續(xù)請教!頭文件編譯時是否也需要添加呢??添加在什么地方???
例如:varde.h, iom162.h, define.h 等這些文件該怎么處理??
   謝謝!

* - 本貼最后修改時間:2005-1-6 15:17:24 修改者:good_ys

9樓: >>參與討論
rose942
請zj4068把你做的文件及資料發(fā)到我郵箱,好嗎?
zj4068:
    你好!
       請把你做的文件及資料發(fā)到我郵箱,好嗎?
       我E_mail:dance942@sohu.com
        謝謝!


10樓: >>參與討論
xij
在dos環(huán)境下,編譯
dos環(huán)境下:
先將多個.c文件,生成.o文件,然后連接成.elf文件,最后生成.hex



11樓: >>參與討論
hotpower
所有添加都是虛的,只需在源文件中包含頭文件
當(dāng)然,記住在make工具中的makefile欄下的C/C++ Source file(s)...項內(nèi)添加多個C文件連接,將include XXX.C(TARGET)打勾并點擊OK即可,多個C文件應(yīng)該以空格隔開...

12樓: >>參與討論
AVRx007
在WINDOWS下
在WINDOWS下,源文件名前不可帶路徑,否則無法在AVRStudio下仿真時顯示各個源文件。

參與討論
昵稱:
討論內(nèi)容:
 
 
相關(guān)帖子
前輩們可否提供BASCOM AVR 的TCPIP庫,急用!
C寫多了,回來寫匯編
我在仿真時發(fā)送的數(shù)據(jù)時亂碼,而且一直不停的發(fā)送
求助:怎么用外部電路修改Mega16的熔絲位(大俠幫忙,很著急)
MEGA128與MEGA64引腳和外圍器件完全兼容嗎?
免費注冊為維庫電子開發(fā)網(wǎng)會員,參與電子工程師社區(qū)討論,點此進入


Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號