共3条
1/1 1 跳转至页
AVRGCC AVRGCC中如何使用浮点数
问
我在使用winAVR GCC时遇到这样一个问题
我定义了一个变量:
volatile double a1;
...
if(CANsu5!=0) a1=1900./CANsu5;
而在编译时总是有一个错误
AVR-gcc -g -Wall -O2 -mmcu=atmega8515 -Wl,-Map,max525.map -o max525.elf max525.o
C:\WinAVR\bin\..\lib\gcc-lib\AVR\3.3.1\..\..\..\..\AVR\bin\ld.exe:
region text is full(max525.elf section .text)
make:***[max525.elf]error 1;
当把这个浮点数定义为整形时如LONG就没问题,不知为何.
我估计是我的MAKE文件不对
以下是我的Makefile:
PRG = max525
OBJ = max525.o
MCU_TARGET = atmega8515
OPTIMIZE = -O2
DEFS =
LIBS =
# You should not have to change anything below here.
CC = AVR-gcc
# Override is only needed by AVR-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -Wl,-Map,$(PRG).map
OBJCOPY = AVR-objcopy
OBJDUMP = AVR-objdump
all: $(PRG).elf lst text eeprom
$(PRG).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
lst: $(PRG).lst
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
# Rules for building the .text rom images
text: hex bin srec
hex: $(PRG).hex
bin: $(PRG).bin
srec: $(PRG).srec
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@
# Rules for building the .eeprom rom images
eeprom: ehex ebin esrec
ehex: $(PRG)_eeprom.hex
ebin: $(PRG)_eeprom.bin
esrec: $(PRG)_eeprom.srec
%_eeprom.hex: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
%_eeprom.srec: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
%_eeprom.bin: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
# Every thing below here is used by AVR-libc's build system and CAN be ignored
# by the casual user.
FIG2DEV = fig2dev
EXTRA_CLEAN_FILES = *.hex *.bin *.srec
dox: eps png pdf
eps: $(PRG).eps
png: $(PRG).png
pdf: $(PRG).pdf
%.eps: %.fig
$(FIG2DEV) -L eps $< $@
%.pdf: %.fig
$(FIG2DEV) -L pdf $< $@
%.png: %.fig
$(FIG2DEV) -L png $< $@
请各位高手指点一下,谢谢! 答 1: 搞定了就是MAKEFILE的问题,用沈文书上的MAKEFILE试了一下就行了 答 2: 要链接浮点库要链接浮点库
我定义了一个变量:
volatile double a1;
...
if(CANsu5!=0) a1=1900./CANsu5;
而在编译时总是有一个错误
AVR-gcc -g -Wall -O2 -mmcu=atmega8515 -Wl,-Map,max525.map -o max525.elf max525.o
C:\WinAVR\bin\..\lib\gcc-lib\AVR\3.3.1\..\..\..\..\AVR\bin\ld.exe:
region text is full(max525.elf section .text)
make:***[max525.elf]error 1;
当把这个浮点数定义为整形时如LONG就没问题,不知为何.
我估计是我的MAKE文件不对
以下是我的Makefile:
PRG = max525
OBJ = max525.o
MCU_TARGET = atmega8515
OPTIMIZE = -O2
DEFS =
LIBS =
# You should not have to change anything below here.
CC = AVR-gcc
# Override is only needed by AVR-lib build system.
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -Wl,-Map,$(PRG).map
OBJCOPY = AVR-objcopy
OBJDUMP = AVR-objdump
all: $(PRG).elf lst text eeprom
$(PRG).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
lst: $(PRG).lst
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
# Rules for building the .text rom images
text: hex bin srec
hex: $(PRG).hex
bin: $(PRG).bin
srec: $(PRG).srec
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@
%.srec: %.elf
$(OBJCOPY) -j .text -j .data -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -j .text -j .data -O binary $< $@
# Rules for building the .eeprom rom images
eeprom: ehex ebin esrec
ehex: $(PRG)_eeprom.hex
ebin: $(PRG)_eeprom.bin
esrec: $(PRG)_eeprom.srec
%_eeprom.hex: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@
%_eeprom.srec: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@
%_eeprom.bin: %.elf
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@
# Every thing below here is used by AVR-libc's build system and CAN be ignored
# by the casual user.
FIG2DEV = fig2dev
EXTRA_CLEAN_FILES = *.hex *.bin *.srec
dox: eps png pdf
eps: $(PRG).eps
png: $(PRG).png
pdf: $(PRG).pdf
%.eps: %.fig
$(FIG2DEV) -L eps $< $@
%.pdf: %.fig
$(FIG2DEV) -L pdf $< $@
%.png: %.fig
$(FIG2DEV) -L png $< $@
请各位高手指点一下,谢谢! 答 1: 搞定了就是MAKEFILE的问题,用沈文书上的MAKEFILE试了一下就行了 答 2: 要链接浮点库要链接浮点库
共3条
1/1 1 跳转至页
回复
| 有奖活动 | |
|---|---|
| 2026年“我要开发板活动”第三季,开始了! | |
| 硬核工程师专属补给计划——填盲盒 | |
| “我踩过的那些坑”主题活动——第002期 | |
| 【EEPW电子工程师创研计划】技术变现通道已开启~ | |
| 发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
| 【EEPW在线】E起听工程师的声音! | |
| 高校联络员开始招募啦!有惊喜!! | |
| 【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
我要赚赏金打赏帖 |
|
|---|---|
| 【FreeRtos】第一个任务的启动过程被打赏¥21元 | |
| 【分享开发笔记,赚取电动螺丝刀】FPB-RA6E2开发板的WDT功能测试被打赏¥22元 | |
| 关于cmakelist特性presets的使用被打赏¥20元 | |
| 【分享开发笔记,赚取电动螺丝刀】M5STACK系列屏幕质量测试程序,竟然有块亮斑?被打赏¥20元 | |
| 【分享开发笔记,赚取电动螺丝刀】快速搭建瑞萨FPB-RA6E2开发板开发环境被打赏¥14元 | |
| 【分享开发笔记,赚取电动螺丝刀】在音频测试中顺序的调整可改变功效被打赏¥18元 | |
| 【分享开发笔记,赚取电动螺丝刀】点阵显示模块及其应用-----献给新年的小礼物被打赏¥22元 | |
| 基于地奇星开发板的数码管模块显示技术被打赏¥23元 | |
| 【分享开发笔记,赚取电动螺丝刀】摇杆模块控制实现LED贪吃蛇游戏被打赏¥33元 | |
| window下生成compilecommands.json的的方法被打赏¥22元 | |
我要赚赏金
