Greetings,
My goal is to have a checksum created for flash memory, store the checksum in EEPROM, and compare the two.
I am using AVRDude to write the checksum value a420 to EEPROM
avrdude: Device signature = 0x1e950f
avrdude> write eeprom 0 0xa4
write eeprom 0 0xa4
avrdude> write eeprom 1 0x20
write eeprom 1 0x20
avrdude> quit
I found example code for calculating the checksum. The code converts the checksum to a string (a420), and reads the values out of EEPROM location 0 and 1, and converts to a string (a420). When the compare occurs, the results indicate they are not equal, I display the value of the checksum (str_Temp4) = a420.
For debug purposes, I change that to display the string created from reading EEPROM 0, 1, and display that value (str1) = a420.
The displayed values are equal, I don't understand why it doesn't pass.
The code:
{
max_1.begin(MAX31865_3WIRE); // set to 3WIRE //Start probe 1
max_2.begin(MAX31865_3WIRE); // set to 3WIRE //Start probe 2
/* --- Initialize display -------------------------------------------------- */
/****************************************************************************/
display.begin(SSD1306_SWITCHCAPVCC);
display.clearDisplay(); //clear display buffer
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(35, 25);
display.setFont(&FreeSansBold9pt7b);
display.print(""); //write to display buffer
display.display(); // diplay contents of display buffer
// init done
pixeltest(); //functional test all pixels of display
delay(2000);
display.clearDisplay(); //clear contents of display buffer
// Checksum routine //
lng_Checksum = 0;
int_Checksum = 0;
for (i = 0; i < 0x3FFF; i++)
{
b = pgm_read_byte_near(i);
lng_Checksum += (uint32_t)b;
}
int_Checksum = (uint16_t)(lng_Checksum & 0x0000FFFF);
itoa (int_Checksum, str_Temp4, 16);
a = EEPROM.read(0);
z = EEPROM.read(1);
itoa (a, str1, 16);
itoa (z, str2, 16);
strcat(str1, str2);
/******************compare checksum to EEPROM*******************/
if (str_Temp4 != str1)
{
while (str_Temp4 != str1) {
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(35, 25);//(30, 25) //sets base of character string
display.setFont(&FreeSansBold9pt7b); //defines Font being used
//display.print(" Ck Err"); //laod display buffer
//display.print(str1); //laod display buffer
display.print(str_Temp4);
display.display(); //display above message
display.clearDisplay();
}
}
else
{
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(30, 25);//(30, 25) //sets base of character string
display.setFont(&FreeSansBold9pt7b);
display.println("V1"); //laod display buffer
display.display(); //display above message
delay(2000);
display.clearDisplay(); //clear contents of display buffer
display.display(); // diplay contents of display buffer
//
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(30, 25);//(30, 25) //sets base of character string
display.setFont(&FreeSansBold9pt7b);
display.println(" PASS"); //laod display buffer
display.display(); //display above message
delay(2000);
display.clearDisplay(); //clear contents of display buffer
display.display(); // diplay contents of display buffer
}
}