190008417 发表于 2012-12-6 15:40:23

ICCAVR6.31 图像数据存放问题

本帖最后由 190008417 于 2012-12-6 15:43 编辑

使用ICCAVR6.31编译环境:
单片机:Atmega128
功能:将一幅图显示在LCD上。
图像数组定义为:
    unsigned char bmp[]={这里面是76800个图像点阵数据};
通过一个显示函数将bmp数组里的图像数据显示在 LCD上。
显示函数定义为void showBMP(unsigned char pic[]);
在MAIN程序里调用为showBMP(bmp);
编译时出现以下错误:
    iccavr -o icebox_test_system -LC:\icc\lib -g -ucrtatmega.o -bfunc_lit:0x8c.0x20000 -dram_end:0x10ff -bdata:0x100.0x10ff -dhwstk_size:16 -beeprom:1.4096 -fihx_coff -S2 @icebox_test_system.lk   -lstudio -lcatmega
want size 9653
lo 256 hi 4351 size 4096
!E <library>(177): area 'data' not large enough
C:\icc\bin\imakew.exe: Error code 1
Done: there are error(s). Exit code: 1

在网上查到错误信息解释为如下:

!E <library>(0): area 'bss' not large enough
want size 1024
lo 260 hi 767 size 508
错误分析:bss段是编译器存放全局数组和局部静态数组的地方。如果我们在编写程序时声明了过大的数组、或局部静态数组,就有可能看到这个提示。
解决方法:如果某些数组是常量,我们就可以增加const关键字,将其放到空间相对宽裕的FLASH中(例如段码表、字模等)。对于其他情况,就只有简化程序或者外扩SRAM存储器了。
!E <library>(101): area 'data' not large enough
错误分析:data段是编译器放置全局变量和静态局部变量的地方。如果我们声明了过多的全局变量和局部静态变量,就有可能看到这个提示。
解决方法:简化程序或者外扩SRAM存储器
我将unsigned char bmp[]={这里面是76800个图像点阵数据}修改为const unsigned char bmp[]={这里面是76800个图像点阵数据}后编译出现以下错误:
!E D:\AVR_PROGRAM\±ùÏä²âÊÔϵͳ\icebox_test_system\LT320240T.C(1210): type error in argument 5 to `ShowBMP'; found `pointer to const unsigned char' expected `pointer to unsigned char'
C:\icc\bin\imakew.exe: Error code 1
C:\icc\bin\imakew.exe: 'LT320240T.o' removed.
Done: there are error(s). Exit code: 1

是不是将字符串数组定义为CONST型后,就不能做为函数的参数了。请各位大侠帮我看一下。

gallle 发表于 2012-12-6 15:52:52

光用const是不起作用的,得组合使用
#pragma data:code//将数组存储到rom中
//LED显示                           h a f b g c e d
const ucharseg56={0X77,0X14,0X5b,0X5d,0X3c,0X6d,0X6f,0X54,0X7F,0X7d,0X7E,0X2f,0X63,0X1f,0X6b,0X08,0};

#pragma data:data //返回ram定义!

190008417 发表于 2012-12-6 16:08:28

gallle 发表于 2012-12-6 15:52 static/image/common/back.gif
光用const是不起作用的,得组合使用
#pragma data:code//将数组存储到rom中
//LED显示                           h a f b g c...


将数组修改为
#pragma data:code
    const unsigned char bmp[]={这里面是76800个图像点阵数据};
#pragma data:data
重新编译还是跟上次一样:

C:\icc\bin\imakew -f icebox_test_system.mak
    iccavr -c -IC:\icc\include\ -e -DATMEGA -DATMega128-l -g -Mavr_enhancedD:\AVR_PROGRAM\冰箱测试系统\icebox_test_system\LT320240T.C
!E D:\AVR_PROGRAM\冰箱测试系统\icebox_test_system\LT320240T.C(1211): type error in argument 5 to `ShowBMP'; found `pointer to const unsigned char' expected `pointer to unsigned char'
C:\icc\bin\imakew.exe: Error code 1
Done: there are error(s). Exit code: 1

“found `pointer to const unsigned char' expected `pointer to unsigned char' ”这条错误信息网上解释为:“ 就是有个带符号字符的指针内容是const,说明这个指针指向的内容不能被修改,而程序需要一个可以被修改内容的char *.原因可能是你传了字符串常量给函数”

   如果要将一个字符常量数组当做函数的参数来使用,请问要怎样操作?

gallle 发表于 2012-12-6 16:18:11

修改程序吧,说的是你的指针溢出了,
你有76800个点,用char型,就是9600Byte。超出了你定义的指针范围了,
把数据分成几个部分试试,左上,左下,右上,右下试试。

190008417 发表于 2012-12-6 16:24:16

gallle 发表于 2012-12-6 16:18 static/image/common/back.gif
修改程序吧,说的是你的指针溢出了,
你有76800个点,用char型,就是9600Byte。超出了你定义的指针范围了, ...

char型,9600Byte是怎么算的呀?我定义的是CHAR型数组,就是说76800个点的数据是字符型的。

first_blood 发表于 2012-12-6 16:28:07

void showBMP(const unsigned char *pic);

190008417 发表于 2012-12-6 16:31:53

first_blood 发表于 2012-12-6 16:28 static/image/common/back.gif
void showBMP(const unsigned char *pic);

还是不对,修改后编译还是出现以下错误:C:\icc\bin\imakew -f icebox_test_system.mak
    iccavr -c -IC:\icc\include\ -e -DATMEGA -DATMega128-l -g -Mavr_enhancedD:\AVR_PROGRAM\冰箱测试系统\icebox_test_system\LT320240T.C
!E D:\AVR_PROGRAM\冰箱测试系统\icebox_test_system\LT320240T.C(1211): type error in argument 5 to `ShowBMP'; found `unsigned char' expected `pointer to unsigned char'
C:\icc\bin\imakew.exe: Error code 1
Done: there are error(s). Exit code: 1

gallle 发表于 2012-12-6 17:34:47

您看看最开始的错误代码
want size 9653
lo 256 hi 4351 size 4096

你这个总共要定义9653个byte变量,但是系统的总大小只有4096个。
所以建议你将它挪到rom区。
但是9600个byte还是大,所以建议您分块。

first_blood 发表于 2012-12-6 18:05:31

void showBMP(const unsigned char *pic);
可以的,我这边就这样编译,没问题。你把整个文件都发上来

first_blood 发表于 2012-12-6 18:07:16

你这个数组定义在flash的,肯定是全局变量,在函数中直接引用即可,不用特意传个const的指针进来的

qwermhb 发表于 2012-12-6 20:55:00

本帖最后由 qwermhb 于 2012-12-6 20:58 编辑

我来个解决办法,这是因为你的数组是在flash里面 ,但是的函数的形参却是在ram 里面,所以你要用const 修饰你的形参,例如ShowPicture(const uchar *p )

Garbage614 发表于 2012-12-6 21:16:59

定义程const然后在iccavr里设置勾选“Treat‘const’as‘——flash’”

190008417 发表于 2012-12-7 08:45:39

qwermhb 发表于 2012-12-6 20:55 static/image/common/back.gif
我来个解决办法,这是因为你的数组是在flash里面 ,但是的函数的形参却是在ram 里面,所以你要用const 修饰 ...

非常感谢,按照你的解决办法,现在可以正确编译了!

190008417 发表于 2012-12-7 08:48:51

Garbage614 发表于 2012-12-6 21:16 static/image/common/back.gif
定义程const然后在iccavr里设置勾选“Treat‘const’as‘——flash’”

首先,感谢你的回复,这种方法我已经试过了,还是不能正确编译,要按照11楼的方法才能正确编译!
页: [1]
查看完整版本: ICCAVR6.31 图像数据存放问题