再次请教,感觉有点奇怪
我在函数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)); |