0
제가함수
EEPROM저장 배열은 어드레스 54 개, 요소 0' 주소 '까지 {0,0,0,0,1,1,1} ...로 시작했다 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'th 소자 영이 아닌 보낸 후 갖는다.
하지만 항상 53을 반환합니다.
왜 그렇게됩니까?
나는 c18 컴파일러를 사용합니다. 논리에 실수가 있다면 저를 바로 잡아주십시오.
감사