Created
September 12, 2016 05:30
-
-
Save trdenton/acc9340e49eae71e031d914bfa869bb1 to your computer and use it in GitHub Desktop.
looking through an eeprom for a known sequence, "AB"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#define disk1 0x50 //Address of 24LC256 eeprom chip | |
void setup(void) | |
{ | |
Serial.begin(9600); | |
Wire.begin(); | |
unsigned int address = 0x3571; | |
//Serial.print(readEEPROM(disk1, address), DEC); | |
long int i; | |
byte last=0x00; | |
byte in =0x00; | |
for(i = 0x3500; i<0x6000; i++) | |
{ | |
last=in; | |
in = readEEPROM(disk1,i); | |
if ((char)in == 'B' && (char)last =='A') | |
{ | |
Serial.print("AB @ "); | |
Serial.println(i-1,HEX); | |
} | |
} | |
} | |
void loop(){} | |
void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data ) | |
{ | |
Wire.beginTransmission(deviceaddress); | |
Wire.write((int)(eeaddress >> 8)); // MSB | |
Wire.write((int)(eeaddress & 0xFF)); // LSB | |
Wire.write(data); | |
Wire.endTransmission(); | |
delay(5); | |
} | |
byte readEEPROM(int deviceaddress, unsigned int eeaddress ) | |
{ | |
byte rdata = 0xFF; | |
Wire.beginTransmission(deviceaddress); | |
Wire.write((int)(eeaddress >> 8)); // MSB | |
Wire.write((int)(eeaddress & 0xFF)); // LSB | |
Wire.endTransmission(); | |
Wire.requestFrom(deviceaddress,1); | |
if (Wire.available()) rdata = Wire.read(); | |
return rdata; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment