打印

虚心请教ROM空间问题

[复制链接]
1884|11
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
utterboy|  楼主 | 2010-6-6 09:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
想请教一下有经验的前辈,当程序大,ROM空间快满的时候,程序会跑乱不?
现在的情况ATMEGA16 flash 16K,我把bootload的设置到最小,可是当我程序大的时候,运行有时候正常,有时不正常,还发现,我把一段程序屏蔽掉,串口好用,能打印东西,把该段程序添加上时,串口就不行了,可是去掉别的程序,加上这段时,是正常的,所以我怀疑当空间快存满的时候,mcu是不是容易跑乱?谢谢各位

相关帖子

沙发
xwj| | 2010-6-6 09:25 | 只看该作者
不会

使用特权

评论回复
板凳
maychang| | 2010-6-6 09:32 | 只看该作者
没有的事。

使用特权

评论回复
地板
buqibushe| | 2010-6-6 09:35 | 只看该作者
不会的,估计是某段代码跳错了位置,或中断出了问题

使用特权

评论回复
5
utterboy|  楼主 | 2010-6-6 17:50 | 只看该作者
谢谢,我将继续努力,找出问题的症结

使用特权

评论回复
6
ar_dong| | 2010-6-7 08:42 | 只看该作者
不知道你用的什么mcu
估计堆栈不够大吧

使用特权

评论回复
7
yuyetufu| | 2010-6-7 09:03 | 只看该作者
你编译好后,看下程序到底有多大?是不是超了? 没超肯定没问题

使用特权

评论回复
8
utterboy|  楼主 | 2010-6-7 10:29 | 只看该作者
to ar_dong
用的atmega16,系统采用多任务调度,堆栈可以设置不

使用特权

评论回复
9
utterboy|  楼主 | 2010-6-7 10:33 | 只看该作者
用AVRstdio仿真时,下载.cof文件时说文件超了,如果烧录时超了,应该软件有提醒吧,

使用特权

评论回复
10
utterboy|  楼主 | 2010-6-7 11:35 | 只看该作者
再次请教,感觉有点奇怪
我在函数overall_data_remain()中调用了几个函数
//read_bak1_from_EEPROM();等多个函数。此时我已经将此函数屏蔽掉不用,
如果我也将这个函数体也屏蔽掉,程序运行正常;如果我不屏蔽掉这些函数体,程序就没有运行(通过看串口,和数码管显示看出程序没在跑),这是为什么呢,我根本没有调入这些函数,与加不加这么函数体有什么关系呢,请教……


我先描述一下情况,请看一下代码
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
void overall_data_remain(void)
{
       
        long eepromdata0[13];
       
        long eepromdata1[13];

        long eepromdata2[13];
        char8 i;
        read_bak0_from_EEPROM();
        eepromdata0[0]=(long)magVar.hefDoor;
        eepromdata0[1]=(long)magVar.sLrOrDouble;
       
        eepromdata0[2]=(long)keyData.keepTime;
        eepromdata0[3]=(long)keyData.openSpeedWap;
        eepromdata0[4]=(long)keyData.closeSpeedWap;
        eepromdata0[5]=(long)keyData.openBufPositonWap;
        eepromdata0[6]=(long)keyData.bufSpeedWap;
        eepromdata0[7]=(long)keyData.closeBufPositonWap;
       
        eepromdata0[8]=(long)keyData1.halfWidthWap;
        eepromdata0[9]=(long)keyData1.halfBufPositionWap;
        eepromdata0[10]=(long)keyData1.senSitiveWap;
       
        eepromdata0[11]=magVar.useNumNote;
        eepromdata0[12]=(long)faultChekData.areaWarpBuf[0];
       
        //read_bak1_from_EEPROM();
        eepromdata1[0]=(long)magVar.hefDoor;
        eepromdata1[1]=(long)magVar.sLrOrDouble;
       
        eepromdata1[2]=(long)keyData.keepTime;
        eepromdata1[3]=(long)keyData.openSpeedWap;
        eepromdata1[4]=(long)keyData.closeSpeedWap;
        eepromdata1[5]=(long)keyData.openBufPositonWap;
        eepromdata1[6]=(long)keyData.bufSpeedWap;
        eepromdata1[7]=(long)keyData.closeBufPositonWap;
       
        eepromdata1[8]=(long)keyData1.halfWidthWap;
        eepromdata1[9]=(long)keyData1.halfBufPositionWap;
        eepromdata1[10]=(long)keyData1.senSitiveWap;
       
        eepromdata1[11]=magVar.useNumNote;
        eepromdata1[12]=(long)faultChekData.areaWarpBuf[0];
       
//        read_bak2_from_EEPROM();
        eepromdata2[0]=(long)magVar.hefDoor;
        eepromdata2[1]=(long)magVar.sLrOrDouble;
       
        eepromdata2[2]=(long)keyData.keepTime;
        eepromdata2[3]=(long)keyData.openSpeedWap;
        eepromdata2[4]=(long)keyData.closeSpeedWap;
        eepromdata2[5]=(long)keyData.openBufPositonWap;
        eepromdata2[6]=(long)keyData.bufSpeedWap;
        eepromdata2[7]=(long)keyData.closeBufPositonWap;
       
        eepromdata2[8]=(long)keyData1.halfWidthWap;
        eepromdata2[9]=(long)keyData1.halfBufPositionWap;
        eepromdata2[10]=(long)keyData1.senSitiveWap;
       
        eepromdata2[11]=magVar.useNumNote;
        eepromdata2[12]=(long)faultChekData.areaWarpBuf[0];

        for(i=0;i<13;i++)
        {
        //uart_puts_P("\n\roverall_data_remain\n\r" );
                if(eepromdata0[i]==eepromdata1[i])
                {
                        eepromdata2[i]=eepromdata1[i];
                }
                if(eepromdata0[i]==eepromdata2[i])
                {
                        eepromdata1[i]=eepromdata2[i];
                }
                if(eepromdata2[i]==eepromdata1[i])
                {
                        eepromdata0[i]=eepromdata1[i];
                }
       
        }
        magVar.hefDoor=(uchar8)eepromdata0[0];
        magVar.sLrOrDouble=(uchar8)eepromdata0[1];
       
        keyData.keepTime=(uchar8)eepromdata0[2];
        keyData.openSpeedWap=(uchar8)eepromdata0[3];
        keyData.closeSpeedWap=(uchar8)eepromdata0[4];
        keyData.openBufPositonWap=(uchar8)eepromdata0[5];
        keyData.bufSpeedWap=(uchar8)eepromdata0[6];
        keyData.closeBufPositonWap=(uchar8)eepromdata0[7];
       
        keyData1.halfWidthWap=(uchar8)eepromdata0[8];
        keyData1.halfBufPositionWap=(uchar8)eepromdata0[9];
        keyData1.senSitiveWap=(uchar8)eepromdata0[10];
       
        magVar.useNumNote=(long)eepromdata0[11];
        faultChekData.areaWarpBuf[0]=(int16)eepromdata0[12];

        write_bak0_into_EEPROM();

       

        magVar.hefDoor=(uchar8)eepromdata0[0];
        magVar.sLrOrDouble=(uchar8)eepromdata0[1];
       
        keyData.keepTime=(uchar8)eepromdata0[2];
        keyData.openSpeedWap=(uchar8)eepromdata0[3];
        keyData.closeSpeedWap=(uchar8)eepromdata0[4];
        keyData.openBufPositonWap=(uchar8)eepromdata0[5];
        keyData.bufSpeedWap=(uchar8)eepromdata0[6];
        keyData.closeBufPositonWap=(uchar8)eepromdata0[7];
       
        keyData1.halfWidthWap=(uchar8)eepromdata0[8];
        keyData1.halfBufPositionWap=(uchar8)eepromdata0[9];
        keyData1.senSitiveWap=(uchar8)eepromdata0[10];
       
        magVar.useNumNote=(long)eepromdata0[11];
        faultChekData.areaWarpBuf[0]=(int16)eepromdata0[12];




        //write_bak1_into_EEPROM();


        magVar.hefDoor=(uchar8)eepromdata0[0];
        magVar.sLrOrDouble=(uchar8)eepromdata0[1];
       
        keyData.keepTime=(uchar8)eepromdata0[2];
        keyData.openSpeedWap=(uchar8)eepromdata0[3];
        keyData.closeSpeedWap=(uchar8)eepromdata0[4];
        keyData.openBufPositonWap=(uchar8)eepromdata0[5];
        keyData.bufSpeedWap=(uchar8)eepromdata0[6];
        keyData.closeBufPositonWap=(uchar8)eepromdata0[7];
       
        keyData1.halfWidthWap=(uchar8)eepromdata0[8];
        keyData1.halfBufPositionWap=(uchar8)eepromdata0[9];
        keyData1.senSitiveWap=(uchar8)eepromdata0[10];
       
        magVar.useNumNote=(long)eepromdata0[11];
        faultChekData.areaWarpBuf[0]=(int16)eepromdata0[12];
        uart_puts_P("\n\roverall data remain \n\r" );

        //write_bak2_into_EEPROM();
}



一下为函数体部分


void  write_bak0_into_EEPROM(void)
{
                eeprom_busy_wait();   
       eeprom_write_byte((uint8_t *)HEF_DOOR_ADDR, magVar.hefDoor);
                eeprom_busy_wait();   
       eeprom_write_byte((uint8_t *)SIGLRD_DOOR_ADDR, magVar.sLrOrDouble);
                eeprom_busy_wait();
       eeprom_write_block ((const void *)&keyData,(void *)SAVE_KEYDATA_ADDR, sizeof(keyData));
       eeprom_busy_wait();
       eeprom_write_block ((const void *)&keyData1,(void *)SAVE_KEYDATA1_ADDR, sizeof(keyData1));
                eeprom_busy_wait();
       eeprom_write_block ((const void *)&magVar.useNumNote,(void *)USE_NUM_ADDR, sizeof(long));
                eeprom_busy_wait();
       eeprom_write_block ((const void *)&faultChekData.areaWarpBuf[0],(void *)AREAWARP_ADDR, sizeof(faultChekData.areaWarpBuf));
                eeprom_busy_wait();   
       eeprom_write_byte((uint8_t *)SUM_ADDR , sumDataCheck());               

}


void  write_bak1_into_EEPROM(void)
{
        eeprom_busy_wait();   
       eeprom_write_byte((uint8_t *)HEF_DOOR_ADDR1, magVar.hefDoor);
        eeprom_busy_wait();   
       eeprom_write_byte((uint8_t *)SIGLRD_DOOR_ADDR1, magVar.sLrOrDouble);
        eeprom_busy_wait();
       eeprom_write_block ((const void *)&keyData,(void *)SAVE_KEYDATA_ADDR1, sizeof(keyData));
       eeprom_busy_wait();
       eeprom_write_block ((const void *)&keyData1,(void *)SAVE_KEYDATA1_ADDR1, sizeof(keyData1));
        eeprom_busy_wait();
       eeprom_write_block ((const void *)&magVar.useNumNote,(void *)USE_NUM_ADDR1, sizeof(long));
        eeprom_busy_wait();
       eeprom_write_block ((const void *)&faultChekData.areaWarpBuf[0],(void *)AREAWARP_ADDR1, sizeof(faultChekData.areaWarpBuf));
        eeprom_busy_wait();   
       eeprom_write_byte((uint8_t *)SUM_ADDR1 , sumDataCheck());       

}

void  write_bak2_into_EEPROM(void)
{
        eeprom_busy_wait();   
       eeprom_write_byte((uint8_t *)HEF_DOOR_ADDR2, magVar.hefDoor);
        eeprom_busy_wait();   
       eeprom_write_byte((uint8_t *)SIGLRD_DOOR_ADDR2, magVar.sLrOrDouble);
        eeprom_busy_wait();
       eeprom_write_block ((const void *)&keyData,(void *)SAVE_KEYDATA_ADDR2, sizeof(keyData));
       eeprom_busy_wait();
       eeprom_write_block ((const void *)&keyData1,(void *)SAVE_KEYDATA1_ADDR2, sizeof(keyData1));
        eeprom_busy_wait();
       eeprom_write_block ((const void *)&magVar.useNumNote,(void *)USE_NUM_ADDR2, sizeof(long));
        eeprom_busy_wait();
       eeprom_write_block ((const void *)&faultChekData.areaWarpBuf[0],(void *)AREAWARP_ADDR2, sizeof(faultChekData.areaWarpBuf));
        eeprom_busy_wait();   
       eeprom_write_byte((uint8_t *)SUM_ADDR2 , sumDataCheck());       

}


////////////////////////////////////////////////////////////////////////
void  read_bak0_from_EEPROM(void)
{       
                eeprom_busy_wait();
                magVar.hefDoor=eeprom_read_byte((const uint8_t *)HEF_DOOR_ADDR);
                eeprom_busy_wait();
                magVar.sLrOrDouble=eeprom_read_byte((const uint8_t *)SIGLRD_DOOR_ADDR);
                eeprom_busy_wait();
                eeprom_read_block ((void *)&keyData, (const void *)SAVE_KEYDATA_ADDR, sizeof(keyData));
                eeprom_busy_wait();
                eeprom_read_block ((void *)&keyData1, (const void *)SAVE_KEYDATA1_ADDR, sizeof(keyData1));
                eeprom_busy_wait();
                eeprom_read_block((void *)&magVar.useNumNote,(const void *)USE_NUM_ADDR, sizeof(long));
                eeprom_busy_wait();
                eeprom_read_block ((void *)&faultChekData.areaWarpBuf[0], (const void *)AREAWARP_ADDR, sizeof(faultChekData.areaWarpBuf));
}


void  read_bak1_from_EEPROM(void)
{
        eeprom_busy_wait();
    magVar.hefDoor=eeprom_read_byte((const uint8_t *)HEF_DOOR_ADDR1);
    eeprom_busy_wait();
    magVar.sLrOrDouble=eeprom_read_byte((const uint8_t *)SIGLRD_DOOR_ADDR1);
    eeprom_busy_wait();
    eeprom_read_block ((void *)&keyData, (const void *)SAVE_KEYDATA_ADDR1, sizeof(keyData));
    eeprom_busy_wait();
    eeprom_read_block ((void *)&keyData1, (const void *)SAVE_KEYDATA1_ADDR1, sizeof(keyData1));
    eeprom_busy_wait();
    eeprom_read_block((void *)&magVar.useNumNote,(const void *)USE_NUM_ADDR1, sizeof(long));
    eeprom_busy_wait();
    eeprom_read_block ((void *)&faultChekData.areaWarpBuf[0], (const void *)AREAWARP_ADDR1, sizeof(faultChekData.areaWarpBuf));               

}

void  read_bak2_from_EEPROM(void)
{
               
                eeprom_busy_wait();
                magVar.hefDoor=eeprom_read_byte((const uint8_t *)HEF_DOOR_ADDR2);
                eeprom_busy_wait();
                magVar.sLrOrDouble=eeprom_read_byte((const uint8_t *)SIGLRD_DOOR_ADDR2);
                eeprom_busy_wait();
                eeprom_read_block ((void *)&keyData, (const void *)SAVE_KEYDATA_ADDR2, sizeof(keyData));
                eeprom_busy_wait();
                eeprom_read_block ((void *)&keyData1, (const void *)SAVE_KEYDATA1_ADDR2, sizeof(keyData1));
                eeprom_busy_wait();
                eeprom_read_block((void *)&magVar.useNumNote,(const void *)USE_NUM_ADDR2, sizeof(long));
                eeprom_busy_wait();
                eeprom_read_block ((void *)&faultChekData.areaWarpBuf[0], (const void *)AREAWARP_ADDR2, sizeof(faultChekData.areaWarpBuf));

使用特权

评论回复
11
utterboy|  楼主 | 2010-6-7 11:36 | 只看该作者
有点乱,函数体在下面,谢谢各位了,愁……

使用特权

评论回复
12
utterboy|  楼主 | 2010-6-7 15:42 | 只看该作者
已经解决了,谢谢

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

87

主题

305

帖子

0

粉丝