这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » ICC,AVRSTUDIO ICC的问题还是AVRSTUDIO的问题 !?

共3条 1/1 1 跳转至

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

院士
2006-09-17 18:14:16     打赏
ICC,AVRSTUDIO ICC的问题还是AVRSTUDIO的问题 !?



关键词: AVRSTUDIO     问题     还是    

院士
2006-12-22 22:43:00     打赏
2楼
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真是垃圾! 1: 还有一个问题:原来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 ! 2: 看看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: }

无语... 3: 难道没有人知道!? UP ! 4: 我猜想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


可以看出非常简洁。 5: 我没启用代码压缩.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

还是那个鬼样子...

至于数组,我是完全没办法了.而且 6: 那我该怎么办?刚想用ICC,听CCTV的一席话,真的有点怕了。ICC、GCC、还有CVAVR哪一个更优秀,对AVR支持更好? 7: 没有人知道?失望! 8: 继续顶~其他人没有遇到过这样的情况吗?我发了mail给IM ,

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

Faint . 我在AVR STUDIO 里调试看过的.绝对是先自加1 然后再进行比较的.搞的我不得不在循环结束再加一条 i--; ,否则循环会提前结束.SHIT ! 9: 自减的循环效率高,用AVR 10: 今天又出了新情况...

调试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 ,这个垃圾已经浪费了我将近一个星期了!

11: 自减效率高 - 这在C51 里体现的比C  AVR 更明显.C51的自加循环效率低多了.

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

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

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

IAR MakeApp&#8482;

我应该用哪种 ? 14: 老相好的不看海了?  给你发个短消息,别回复,现在用的是MyIE2禁止弹出窗口,给我发我也看不到。AVR只用过一次,就是破电话卡,用完了也就完了,有两年没搞过乐。 15: 为什么一定要使用绝对定位呢?为什么一定要使用绝对定位呢?如果什么地址都要自己分配,还不如用汇编。 16: 收到,谢谢!太久没来21IC了,马甲的密码都不太记得了...试了好久...才登陆上来,哈哈.

短消息收到,非常感谢!

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

现在的21IC人气比以前旺了很多,却没有以前那种氛围了.大家都很冷漠. 17: 这么多编译器的定位功能都是多余的了 ?昨晚看完了CVAVR 的SPC ,功能确实比ICC周到多了.文档也写的很好.清楚明了,调理分明.很容易找到自己想要的东西.我觉得ICC的文档纯粹是乱七八糟的堆砌,一定是语文没学好,呵呵.

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

我在AVR 完全是新手,很多时候不知道是自己的问题还是编译器的问题或者其他什么问题.有高手来指点非常荣幸且高兴,但老兄说出这么牵强的话来,失望. 18: 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. 19: 谢谢你的回答.你比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.

专家
2022-08-20 15:36:12     打赏
3楼

厉害了


共3条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]