I have an EEPROM and I'm storing data in it, from address 0x00
to 0xff
. I have to scan the EEPROM regularly for non zero values.
eg:
address 0x00 0x01 0x02 0x03 0x04......0x0A 0x0B 0x0C.........0xFF
values 0 0 1 1 0 0 1 0 0
If I do a scanning function to find first address of value I'm able to do it. But, how will I bypass the first detected address (0x02
), and find the next address in the second call of function?
Note: If we encountered more than one consecutive 1's, then the first address is taken (0x02
).
I will be extremely happy if you provide some technique to tackle this.
int scaneeprom(void)
{ static unsigned int x,
static unsigned int counter;
for(i=0+counter; i<255;i++)
{
while((eepromread(i++)!)==0)
{
x=i;
counter++;
}
return(i);
}
This is suppose to scan from 0x04-0xff on the second call.
I would appreciate your input that will rectify my mistake.