atmega8程序大小限制?

时间:2012-09-21 06:57:49

标签: avr atmega

我是atmega8的新手。我将一些旧的freesacle代码转换为atmega8。但似乎我的芯片不能容纳超过2400字节的代码?下面是结果,当代码是2412字节时......一切都变得一团糟。

avrdude下面的代码来自" cat / dev / ttyUSB0"。我的调试信息。

avrdude: verifying ...
avrdude: 2412 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

55432111001-0000 6Gn�H(�h�X0443234554321190 6Gn�H        (�h�X0443234554321100-FD-90-6F55432111001-0000 6Gn�H    (�h�X0443234554321190 6Gn�H(�h�X0443234554321100-FD-90-6F^C

但如果我减少了代码(只有音频数据),我得到了正确的结果。

avrdude: verifying ...
avrdude: 2312 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done.  Thank you.

AVR-IrDA-Tone-Audio start.
version 1.2
--IrDA--    Bin: 1001-0000      Hex: 90     Complete Hex: 00-FD-90-6F

所有hfuse,lfuse,锁定位都是原始值。我的代码可能是6k,带有一些音频数据。

如果是由于启动闪存部分?

添加:--------------------------------------------- -------------------------------------------------- ---

我现在将水晶变成了8M。

● ll h8-*
-rw-rw-r-- 1 eexp eexp 933  9月 22 00:27 h8-reduce.c
-rw-rw-r-- 1 eexp eexp 14K  9月 22 00:26 h8-org.c

● cp h8-org.c h8.c

● avr.sh main.c
......
avrdude: 5272 bytes of flash verified
现在一切都变得一团糟。

● cp h8-reduce.c h8.c

● avr.sh main.c
.....
avrdude: 1872 bytes of flash verified

现在一切顺利,但我几乎丢失了所有音频数据。

下面是h8.c。

● head h8.c
const unsigned char h8[] =
{
    36,14,0,0,129,129,128,129,130,127,126,128,128,127,128,130,131,128,127,127,127,126,127,129,130,130,129,129,128,128,128,128,128,126,126,129,128,127,127,130,133,130,126,126,129,128,125,127,128,129,128,127,129,128,127,127,127,128,128,129,127,127,129,128,130,130,128,128,127,126,128,128,128,130,129,128,129,126,126,125,127,132,130,127,126,129,131,127,127,133,133,127,122,125,129,130,127,127,130,129,
    126,125,127,128,129,128,128,128,128,127,127,129,128,129,129,128,126,127,129,127,128,127,128,130,129,129,128,128,127,127,129,130,128,128,129,129,127,127,128,128,128,128,128,128,126,126,129,129,127,129,130,130,126,126,128,128,127,128,131,130,127,126,126,128,129,125,128,130,131,128,126,129,128,129,125,126,130,129,131,130,131,129,125,128,129,131,130,127,130,129,127,128,127,129,128,126,126,127,128,126,
    127,127,128,128,128,127,127,127,127,127,129,128,129,128,128,129,129,128,128,129,128,128,128,129,0xff,
};

1 个答案:

答案 0 :(得分:1)

我猜您正在将音频数据加载到ram中。像

这样的变量声明
  char* data = "somerandomdata"; 

将所有数据放入SRAM中,而mega8中只有1kbyte的SRAM(也包含堆栈等)。

如果锁定位处于其原始状态,则引导加载程序机制不应导致此错误。

你应该将音频数据指定为程序空间,这里是如何描述:

Avr LibC PGM Space

以下是您的代码应如何显示: h4.c

       #include <avr/pgmspace.h>

       const unsigned char h4[] PROGMEM = { 18,7,0,0,128,128,128,127,127,129,129,127,126,128,130,129,128,129,127,127,128,12‌​8,132,127,129,126,128,128,127,127,127,129,127,127,130,129,127,127,129,130,129,125‌​,

你需要调整你的set_audio功能, 指针h4的每次读取都应以这种方式完成: 改变例如

  value = *h4_copy++;

  value = pgm_read_byte(h4_copy); h4_copy++;