7
7
8
8
/*
9
9
10
+ For more details, photos, wiring, instructions, see:
11
+
12
+ http://www.gammon.com.au/forum/?id=11638
13
+
14
+
10
15
Copyright 2012 Nick Gammon.
11
16
12
17
@@ -380,6 +385,14 @@ void showProgress ()
380
385
Serial.print (F (" #" )); // progress bar
381
386
} // end of showProgress
382
387
388
+ // clear entire temporary page to 0xFF in case we don't write to all of it
389
+ void clearPage ()
390
+ {
391
+ unsigned int len = signatures [foundSig].pageSize ;
392
+ for (int i = 0 ; i < len; i++)
393
+ writeFlash (i, 0xFF );
394
+ } // end of clearPage
395
+
383
396
// commit page to flash memory
384
397
void commitPage (const unsigned long addr)
385
398
{
@@ -395,8 +408,10 @@ void commitPage (const unsigned long addr)
395
408
396
409
program (writeProgramMemory, highByte (addr >> 1 ), lowByte (addr >> 1 ));
397
410
pollUntilReady ();
398
- } // end of commitPage
399
411
412
+ clearPage (); // clear ready for next page full
413
+ } // end of commitPage
414
+
400
415
// write data to temporary buffer, ready for committing
401
416
void writeData (const unsigned long addr, const byte * pData, const int length)
402
417
{
@@ -624,6 +639,7 @@ boolean readHexFile (const char * fName, const byte action)
624
639
Serial.println (F (" Erasing chip ..." ));
625
640
program (progamEnable, chipErase); // erase it
626
641
pollUntilReady ();
642
+ clearPage (); // clear temporary page
627
643
Serial.println (F (" Writing flash ..." ));
628
644
break ;
629
645
} // end of switch
0 commit comments