iar for avr 5.11b,编译时代码里的字符串占用全局ram,怎样设置不会占用全局ram?
下面两个函数产生的结果如下。字符串少了4个字,code和ram都小了4字节。说明占用了全局的RAM。不划算呀,log那么多。两下就用完ram了。Dprintf("hello=%d\n",123);
Dprintf("k=%d\n",123);
31 086 bytes of CODE memory (+ 56 range fill )
1 845 bytes of DATA memory (+ 35 absolute )
31 082 bytes of CODE memory (+ 56 range fill )
1 841 bytes of DATA memory (+ 35 absolute ) 把字符串定义成数组,加上const 修饰,调用的时候用数组名调用。你试试行不行 peteryzm 发表于 2020-6-6 15:59
把字符串定义成数组,加上const 修饰,调用的时候用数组名调用。你试试行不行 ...
这样太麻烦,还不如调试完后直接注释掉 空掉这个设置后编译,出现这个错误
Edesigner. 发表于 2020-6-6 16:08
空掉这个设置后编译,出现这个错误
设置了 楼上的配置后,字符串归类到CONST,但修改了字符串长度后CONST 会改变,但hex文件是一样的。不懂怎么搞
31 076 bytes of CODEmemory (+ 56 range fill )
1 835 bytes of DATAmemory (+ 35 absolute )
38 bytes of CONST memory
我的 做法是
const char test[] = {"uart test\0"};
uart_printf("%s", test);
avr-gcc是加上PROGMEM关键字,不过之后调用的函数都要换带_p后缀的版本 方法在这里:
https://www.iar.com/support/tech-notes/linker/the-output-format-cannot-handle-multiple-address-spaces/ 不过我最后还是没有使用,因为对库函数有影响。
页:
[1]