登录 免费注册 首页 | 行业黑名单 | 帮助
维库电子市场网
技术交流 | 电路欣赏 | 工控天地 | 数字广电 | 通信技术 | 电源技术 | 测控之家 | EMC技术 | ARM技术 | EDA技术 | PCB技术 | 嵌入式系统
驱动编程 | 集成电路 | 器件替换 | 模拟技术 | 新手园地 | 单 片 机 | DSP技术 | MCU技术 | IC 设计 | IC 产业 | CAN-bus/DeviceNe

ICC的问题还是AVRSTUDIO的问题 !?

作者:cctv 栏目:单片机
ICC的问题还是AVRSTUDIO的问题 !?
ICC AVR6.28:
我在程序中定义了一些表:
#pragma data:program
#pragma abs_address:0x300
CHAR asciitohex[]={0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,0,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};
CHAR hextoascii[]={"0123456789ABCDEF"};
.....
#pragma end_abs_address
#pragma data:data

用AVRSTUDIO打开HEX文件定位是正确的.可是用AVRSTUDIO打开COF文件就是一塌糊涂! 我试了3.5和4.07两个版本,都有这个问题.到底是ICC的问题还是ABRSTUDIO的问题 !? 急!

还有...ICC的文档真是...垃圾...,比如关于#pragma data: 的用法也只有两个简单的例子,根本没有讲清楚!

面向MCU的C都不可能完全兼容ANSI C的,写点文档这么难啊! 做完这单我就换了,宁可用GCC ....ICC真是垃圾!

2楼: >>参与讨论
cctv
还有一个问题:原来FOR(;;) 循环还可以这样编译...
197:        { for (k=0;k-6;k++)
+000002DA:   9563        INC     R22              Increment
197:        { for (k=0;k-6;k++)
+000002DB:   2F86        MOV     R24,R22          Copy register
+000002DC:   5086        SUBI    R24,0x06         Subtract immediate
+000002DD:   F6C9        BRNE    +0x59            Branch if status flag cleared


变成for (k=0;k-6;++k) 了!
AVR 都是这样的吗 ? 作者是不是从右往左看字的...

FAINT !

3楼: >>参与讨论
cctv
看看KEIL 是怎么编译的...
     3:  for (i=0;i-5;i++) i++;
C:0x0003    E4       CLR      A
C:0x0004    FF       MOV      R7,A
C:0x0005    EF       MOV      A,R7
C:0x0006    24FB     ADD      A,#0xFB
C:0x0008    6004     JZ       C:000E
C:0x000A    0F       INC      R7
C:0x000B    0F       INC      R7
C:0x000C    80F7     SJMP     C:0005
     4: }

无语...

4楼: >>参与讨论
cctv
难道没有人知道!? UP !
 
5楼: >>参与讨论
powerpan
我猜想
icc的编译好像有点问题。
而且你用了绝对地址放置数据。如果你没有打开代码优化的话,编译出错是不可理解的。关键应该是你是否打开了优化。

还有你说的for循环,本来他们的编译器就不好。而且你试看看定义

CHAR i
for (i=20;i>=0;i++)你看编译之后正常不?

GCC如果放置太多的data之后程序就死了,不敢用。

我觉得CVAVR非常不错,编译效率比较高。
例子:
;244      for (i=0;i<PWMDELAY;i++)
    LDI  R16,LOW(0)
_0x2B:
    CPI  R16,10
    BRGE _0x2C
;245    #asm ("nop");                      
    nop
    SUBI R16,-1
    RJMP _0x2B


可以看出非常简洁。

6楼: >>参与讨论
cctv
我没启用代码压缩.
3:        for (i=20;i>=0;i++);
+00000033:   E104        LDI     R16,0x14         Load immediate
+00000034:   C001        RJMP    +0x0001          Relative jump
3:        for (i=20;i>=0;i++);
+00000035:   9503        INC     R16              Increment
3:        for (i=20;i>=0;i++);
+00000036:   3000        CPI     R16,0x00         Compare with immediate
+00000037:   F7E8        BRCC    +0x7D            Branch if status flag cleared

还是那个鬼样子...

至于数组,我是完全没办法了.而且

7楼: >>参与讨论
mrqingfeng
那我该怎么办?
刚想用ICC,听CCTV的一席话,真的有点怕了。ICC、GCC、还有CVAVR哪一个更优秀,对AVR支持更好?

8楼: >>参与讨论
cctv
没有人知道?失望!
 
9楼: >>参与讨论
cctv
继续顶~其他人没有遇到过这样的情况吗?
我发了mail给IM ,

"I can assure you the code is correct. Check it carefully and see."

Faint . 我在AVR STUDIO 里调试看过的.绝对是先自加1 然后再进行比较的.搞的我不得不在循环结束再加一条 i--; ,否则循环会提前结束.SHIT !

10楼: >>参与讨论
wanglele
自减的循环效率高,用AVR
 
11楼: >>参与讨论
cctv
今天又出了新情况...


调试EEPROM 程序,在mian()开头用了如下定义:
#pragma data:EEPROM
#pragma abs_address:0x000
CHAR ep_password[]={0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38};
#pragma end_abs_address

#pragma data:data
CHAR temps;

紧接着刚好是一个中断函数
#pragma interrupt_handler timer1_ovf_isr:9
void timer1_ovf_isr(void)
{
}

现在程序一启动就到了timer1_ovf_isr函数了,真TMD 搞笑!

现在正在苦苦调试...如果今晚不解决,明天开始啃CVAVR ,这个垃圾已经浪费了我将近一个星期了!



12楼: >>参与讨论
cctv
自减效率高 - 这在C51 里体现的比C  AVR 更明显.
C51的自加循环效率低多了.

我是想知道为什么会出这种低级的编译错误.以及如何避免.

并不是什么时候都可以用自减循环的.



13楼: >>参与讨论
cccp
ICC和CV都用过,效率名气远不如IAR。或者试试GCC。
 
14楼: >>参与讨论
cctv
汗...用CCCP专用表情的后果...请教CCCP
我到IAR的主页看过了,有两种产品:
IAR Embedded Workbench Professional

IAR MakeApp&#8482;

我应该用哪种 ?

15楼: >>参与讨论
cccp
老相好的不看海了?
  给你发个短消息,别回复,现在用的是MyIE2禁止弹出窗口,给我发我也看不到。AVR只用过一次,就是破电话卡,用完了也就完了,有两年没搞过乐。

16楼: >>参与讨论
avr
为什么一定要使用绝对定位呢?
为什么一定要使用绝对定位呢?如果什么地址都要自己分配,还不如用汇编。

17楼: >>参与讨论
seeseatv
收到,谢谢!
太久没来21IC了,马甲的密码都不太记得了...试了好久...才登陆上来,哈哈.

短消息收到,非常感谢!

有没有MSN 或者 QQ ,怕以后还有问题请教,呵呵.

现在的21IC人气比以前旺了很多,却没有以前那种氛围了.大家都很冷漠.

18楼: >>参与讨论
seeseatv
这么多编译器的定位功能都是多余的了 ?
昨晚看完了CVAVR 的SPC ,功能确实比ICC周到多了.文档也写的很好.清楚明了,调理分明.很容易找到自己想要的东西.我觉得ICC的文档纯粹是乱七八糟的堆砌,一定是语文没学好,呵呵.

要做就做好,要么就别做.很简单的道理.

我在AVR 完全是新手,很多时候不知道是自己的问题还是编译器的问题或者其他什么问题.有高手来指点非常荣幸且高兴,但老兄说出这么牵强的话来,失望.

* - 本贴最后修改时间:2003-8-15 17:01:39 修改者:seeseatv

19楼: >>参与讨论
音乐乐乐
cctv:很明显的使用错误!
#pragma abs_address:0x000
CHAR ep_password[]={0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38,0x00,0x38};
#pragma end_abs_address


#pragma abs_address:是对程序存储器用的,而你的数组定义却没有加const关键字!

The AVR is a Harvard architecture machine, separating program MEMORY from data MEMORY. There are several advantages to such a design. For example, the separate address space allows an AVR DEVICE to access more total MEMORY than a conventional architecture. For example, the ATmega series allows up to 64K words of program MEMORY and 64K bytes of data MEMORY, and future DEVICEs with possibly even greater amounts of program MEMORY may be available later. However, the program counter still remains at 16 bits.

Unfortunately, C was not invented on such a machine. In particular, C pointers are either data pointers or function pointers, and C rules already specify that you cannot assume data and function pointers can be converted BACK and forth. However, with a Harvard architecture machine like the AVR, even a data pointer may point to either data MEMORY or to program MEMORY.
There are no STANDARD C rules for how to handle this. The ImageCraft AVR compiler uses the "const" qualifier to signify that an ITEM is in the program MEMORY. Note that for a pointer declaration, the const qualifier may appear in different places, depending whether it is qualifying the pointer variable itself or the ITEMs that it points to. For example:

const int table[] = { 1, 2, 3 };
const CHAR *ptr1;
CHAR * const ptr2;
const CHAR * const ptr3;

"table" is a table ALLOCATED in the program MEMORY. "ptr1" is an ITEM in the data MEMORY that points to data in the program MEMORY. "ptr2" is an ITEM in the program MEMORY that points to data in the data MEMORY. Finally, "ptr3" is an ITEM in the program MEMORY that points to data in the program MEMORY. In most cases, ITEMs such as "table" and "ptr1" are probably the most typical. The C compiler generates the LPM instruction to access the program MEMORY.
Note that the C STANDARD does not require "const" data to be put in the read-ONLY MEMORY, and in a conventional architecture, this would not matter except for access rights. So, this use of the const qualifier is unconventional, but within the allowable parameters of the C STANDARD. However, this does introduce conflicts with some of the STANDARD C function definitions.

For example, the STANDARD prototype for "strcpy" is strcpy(CHAR *dst, const CHAR *src), with the const qualifier of the second argument signifying that the function does not modify the argument. However, under ICCAVR, the const qualifier would indicate that the second argument points to the program MEMORY which is likely not the case. Thus these functions are defined without the const qualifiers.
Finally, note that ONLY const variables with file storage class will be put into FLASH. For example, variables that are defined outside of a function body or variables that have the static storage class have file storage class. If you declare local variables with the const qualifier, they will not be put into FLASH and undefined behaviors may result. The compiler emits a warning when it detects this situation.

20楼: >>参与讨论
seeseatv
谢谢你的回答.你比IMAGE CRAFT的客服强多了.
那个署名"Richard F. Man <richard@imagecraft.com>"的客服只给我了一个愚蠢的回答:"I can assure you the code is correct. Check it carefully and see." 搞笑!

1 你在哪里找到上面的说明的? 我在HELP里没找到哦.

2 你的回答解决我在FLASH 里定位数组的问题.谢谢!我只所以用#pragma data:program和#pragma abs_address:0x300来定位代码,因为ICC里的文档只说他们是用来定位的,但没说明定位的对象.于是我想当然的用来定位FLASH数据了,呵呵.

3 EEPROM 的定位还是没解决.#pragma data:EEPROM #pragma abs_address:0x000一旦使用,编译就会严重出错:程序都不是从main()开始运行了.

4 我对ICC可以说是失望透了.前天看完CVAVR的文档有决定转向CV.虽然CV不如IAR强大,但已经够用了.而ICC ,只能说是一个toy 而已,30天的试用时间确实enough.

21楼: >>参与讨论
音乐乐乐
不知道你用的什么型号的
  


* - 本贴最后修改时间:2003-8-16 18:29:18 修改者:音乐乐乐

22楼: >>参与讨论
音乐乐乐
不知道你用的什么型号
象90S8515,EEPROM的0地址是不能用的
放在其他地址试试,如0x0020

那是在ICC的帮助文件里的,是你没有好好的看呀

不过那个帮助文件做的很不好,没有搜索功能!



23楼: >>参与讨论
seeseatv
偶用的MEGA8 ,HELP文档都是不能搜索的,深恶痛绝啊.
 
24楼: >>参与讨论
音乐乐乐
谁说都不能,Visual系列的
MSDN就可以的



参与讨论
昵称:
讨论内容:
 
 
相关帖子
请问:MEGA8用5V供电,那么AREF引脚最高可接多少伏?
AVRStudio4.07的问题
mega128的icc问题
在哪里可以下载一些examples codes
延时问题
免费注册为维库电子开发网会员,参与电子工程师社区讨论,点此进入


Copyright © 1998-2006 www.dzsc.com 浙ICP证030469号