返回列表 发新帖

XMega128A1+AVR Studio 5.0代码空间限制问题

[复制链接]

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-7-14 08:22:10 | 显示全部楼层 | 阅读模式
首先声明程序肯定没问题,编译也没问题,显示代码空间用掉40%,数据空间用掉37%,下载后无法运行。注释掉部分代码,重新编译,代码空间用掉37%,数据空间用掉30%,就能运行了。百思不得其解,请高手指教如何去除代码限制。谢谢。
回复

使用道具 举报

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-7-14 09:26:07 | 显示全部楼层
查了一下官方手册:http://www.atmel.com/zh/cn/System/whats_changed.aspx?Products=010 Atmel AVR 8- and 32-bit Microcontrollers第12页,说要访问大于64KB的代码空间或数据空间,必须使地址指针长度大于16位。要使用RAMPX+X,RAMPY+Y,RAMPZ+Z分别组成24位地址就可以了,问题是应该如何赋值呢?
回复 支持 反对

使用道具 举报

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-7-17 10:28:24 | 显示全部楼层
------ Rebuild All started: Project: DataCollector, Configuration: Release AVR ------
Build started.
Project "DataCollector.avrgccproj" (ReBuild target(s)):
Target &quotreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreRebuild" in file "D:\\Program Files\\Atmel\\AVR Studio 5.0\\Vs\\AvrGCC.targets" from project "F:\\work\\PortableStation\\DataCollector\\DataCollector.avrgccproj" (target "ReBuild" depends on it):
    Task "RunAvrGCC"
        d:\\Program Files\\Atmel\\AVR Studio 5.0\\AVR ToolChain\\bin\\make.exe clean all
        rm -rf  "Hardware Layer/adc_driver.o" &quotresentation Layer/mainFun.o" "Hardware Layer/adc_driver.d" &quotresentation Layer/mainFun.d"   libDataCollector.a  DataCollector.hex  DataCollector.eep  DataCollector.lss DataCollector.map
adc_driver.c
        Invoking: AVR/GNU C Compiler
        "d:/Program Files/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-gcc.exe" -funsigned-char -funsigned-bitfields -Os -ffunction-sections -fpack-struct -fshort-enums -Wall -c -std=gnu99  -mmcu=atxmega128a1   -MD -MP -MF"adc_driver.d" -MQ"Hardware Layer/adc_driver.d" -o"Hardware Layer/adc_driver.o" "../Hardware Layer/adc_driver.c"
        Finished building: ../Hardware Layer/adc_driver.c
mainFun.c
        Invoking: AVR/GNU C Compiler
        "d:/Program Files/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-gcc.exe" -funsigned-char -funsigned-bitfields -Os -ffunction-sections -fpack-struct -fshort-enums -Wall -c -std=gnu99  -mmcu=atxmega128a1   -MD -MP -MF"mainFun.d" -MQ&quotresentation Layer/mainFun.d" -o&quotresentation Layer/mainFun.o" "../Presentation Layer/mainFun.c"
        Finished building: ../Presentation Layer/mainFun.c
        Building target: DataCollector.elf
        Invoking: AVR/GNU C/C++ Linker
        "d:/Program Files/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-gcc.exe" -Wl,-L"D:\\Program Files\\Atmel\\AVR Studio 5.0\\AVR Toolchain\\avr\\lib"   -mmcu=atxmega128a1  -Wl,-Map=DataCollector.map -o DataCollector.elf  "Hardware Layer/adc_driver.o" &quotresentation Layer/mainFun.o"  -Wl,-lm
        Finished building target: DataCollector.elf
        "d:/Program Files/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature  "DataCollector.elf" "DataCollector.hex"
        "d:/Program Files/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-objdump.exe" -h -S "DataCollector.elf" > "DataCollector.lss"
        "d:/Program Files/Atmel/AVR Studio 5.0/AVR ToolChain/bin/avr-objcopy.exe" -j .eeprom --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex "DataCollector.elf" "DataCollector.eep" || exit 0
        AVR Memory Usage
        ----------------
        Device: atxmega128a1
        Program:   57894 bytes (41.6% Full)
        (.text + .data + .bootloader)
        Data:       2839 bytes (34.7% Full)
        (.data + .bss + .noinit)
    Done executing task "RunAvrGCC".
Done building target "CoreRebuild" in project "DataCollector.avrgccproj".
Target &quotostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').
Target "ReBuild" in file "D:\\Program Files\\Atmel\\AVR Studio 5.0\\Vs\\Avr.common.targets" from project "F:\\work\\PortableStation\\DataCollector\\DataCollector.avrgccproj" (entry point):
Done building target "ReBuild" in project "DataCollector.avrgccproj".
Done building project "DataCollector.avrgccproj".

Build succeeded.
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
就是这个结果。不能运行。
回复 支持 反对

使用道具 举报

718

主题

5889

帖子

2万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
23770
发表于 2012-7-17 14:47:02 | 显示全部楼层
请贴工程
回复 支持 反对

使用道具 举报

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-7-27 09:54:42 | 显示全部楼层
Dear customer,


As your application code is 57894 bytes (and thus below 64kB) the RAMPX/Y/
Z registers should not be the problem. Furthermore, having application code
larger than 64kB is not a problem in itself. It's only when using avr-gcc
(not IAR) and the PROGMEM attribute to store large amounts of arrays/
function pointers etc. in flash that this may become an issue. You can find
more information about this in the AVR-LibC documentation here:
http://www.nongnu.org/avr-libc/u ... avr__pgmspace.html.


In order to be of assistance it would be helpful to have some more detailed
information.
- When you say stops running, what do you mean? Please provide a more
detailed description of the failure.
- Is it possible that the error is in the code that you have added lately,
as you suspect the size to be the problem?
- Have you tried using a debugger to see where it stops?
- What programmer/debugger are you using?
- What compiler optimization levels are you using?
- Are you using a custom boot loader (or anything else out of the
ordinary)?



Best Regards,
Sigurd Baardsen
Atmel Technical Support Team
这个是老外给我的答案。
回复 支持 反对

使用道具 举报

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-7-27 09:59:28 | 显示全部楼层
我的优化选项:文件大小。
下载器:Atmel AVR MKII ISP
调试器:Mcuzone 的 MKII 仿真器。
现在文件大小在47%左右就无法执行了,很奇怪。另外从老外表述来看,用AVR Studio(使用AVR GCC编译器)确实存在64K问题。
回复 支持 反对

使用道具 举报

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-7-28 09:39:59 | 显示全部楼层
Dear Sir:
Thanks for your answer.
I am using a Real Time Clock to give out a pulse per second, which triggers an interrupt. In the service function I control a LED to flash as follows:

ISR(PORTC_INT1_vect)
{
LED_ON();
//do something
LED_OFF();
}
    When I say it stops running, I mean the LED stop flashing. Any more, the uart ports stop working. But if I comment out some codes which run perfectly before, and
rebuild the project and then download the Hex, it will recover.
    I am using AVRISP MKII.
    Optimization levels: Filesize.
    I am not using any bootloader.

    Now the filesize is 47%. I have managed to make it run via programming more times. But I am confused that if I use AVR Studio 5, the 64K problem does exist because
of the AVR GCC compiler? If so, it will make me depressed. Will Atmel solve the problem in the future version?
Thanks again. Best regards to you.

偶的继续提问。
回复 支持 反对

使用道具 举报

5

主题

28

帖子

5

积分

一年级

积分
5
发表于 2012-7-28 09:40:52 | 显示全部楼层
Dear Customer,

From the description of your issue, it sounds like your interrupt routine for PORTC_INT1_vect is failing to complete - i.e. the "// do something" portion of your sample code is blocking in some manner, preventing the interrupt routine from completing. You will need to debug your code on your device (or, if possible, simulate it from within Atmel Studio) to determine if this is the case and if so how to fix it. If the interrupt routine is not completing, your code sample would turn on the LED and not turn it off again, so if your board LED remains on when the program fails, this is likely the root cause.

I am unable to determine what GCC issue you are referring to with regards to the second half of your email, however AVR Studio 5 is deprecated and no longer maintained. Please upgrade to the latest Atmel Studio 6 (from http://www.atmel.com/tools/ATMELSTUDIO.aspx ) to obtain the latest Atmel AVR-GCC toolchain and associated utilities - this is a direct replacement for AVR Studio 5 with the same user interface and contains new features and bug fixes only.

Best Regards,
Dean Camera
Atmel Technical Support Team

老外的回答。
回复 支持 反对

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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