0
我已经存储在EEPROM功能用于EEPROM搜索
阵列与{0,0,0,0,1,1,1 ...}开始直到从地址54个元素个“0'地址” 53',我已经交叉检查了值,一切都很好。
但是当我采用了“搜索功能”和我已经通过了“0”作为参数,因为它从第0地址搜索。
无符号字符搜索(炭的current_time)
{
unsigned int loopcnt = 0;
unsigned int add ;
unsigned char addr = 0; //We will store start address of 1's here
unsigned char lastAddr =current_time;
unsigned int x;
add = 0;
//If lastAddr is already overflowing, reset it
if(lastAddr >= 53)
{
lastAddr = 0;
addr=53;
return(addr);
}
for(loopcnt = lastAddr; loopcnt < 54; loopcnt++)
{
addr = loopcnt;
x=eeread(add);
//This is start location of our scanning
while(x!= 0)
{
x=eeread(add);
loopcnt++;
add++;
//Count the 1's we got!
if(loopcnt==53)
{
addr=53;
break;
}
}
}
return (addr);
}
但它有自后的“第4'元素是非零返回“4”作为值。
但它返回53始终。
为什么会这样呢?
进出口使用C18 compiler..If存在逻辑错误,任何你指正。
问候