Sample code for how to erase/write LPC1768, LPC11U24, LPC1114, LPC812 and LPC824 internal flash memory. This program uses IAP call of MCU's ROM routines. The IAP library also supports read/write of EEPROM in LPC11U24.

Dependencies:   mbed IAP

Sample code for how to erase/write LPC1768, LPC11U24, LPC1114, LPC812 and LPC824 internal flash memory. This program uses IAP call of MCU's ROM routines.

No filesystem interface available. This program is just an interface to flash erasing and writing. User need manage where to store the data in the flash area.

This IAP library supports read/write of EEPROM in LPC11U24.

More information available in
http://mbed.org/users/okano/notebook/iap-in-application-programming-internal-flash-eras/

Revision:
8:7d4d4edcb133
Parent:
7:e140563d4aad
diff -r e140563d4aad -r 7d4d4edcb133 main.cpp
--- a/main.cpp	Wed Aug 15 07:42:33 2018 +0000
+++ b/main.cpp	Thu Aug 16 06:12:15 2018 +0000
@@ -45,6 +45,7 @@
  *        revision 3.1.1 16-Jan-2015  Target MCU name changed for better compatibility across the platforms
  *        revision 3.1.2 10-Mar-2015  merged with pull requests. reinvoke_isp() added and modified read_serial() to return a pointer.
  *        revision 3.1.2.1 15-Aug-2018  added: just minor feature in "memdump()" function
+ *        revision 3.1.3   16-Aug-2018  "write page" function demo for LPC81X/LPC82X
  */
 
 #include    "mbed.h"
@@ -63,6 +64,7 @@
 #endif
 
 void    memdump( char *p, int n );
+int     write_page( char *src, int target_page );
 
 IAP     iap;
 
@@ -140,9 +142,24 @@
 
     printf( "\r\nerase page test\r\n" );
     printf( "erase page result     = \"%s\"\r\n", r ? "FAILED" : "OK" );
-    printf( "showing memory dump to confirm 0x00003C40 to 0x00003C7F are erased (should be changed to 0xFF)" );
+    printf( "showing memory dump to confirm 0x00003C40 to 0x00003C7F are erased\r\n(should be changed to 0xFF)\r\n" );
 
     memdump( sector_start_adress[ TARGET_SECTOR ], MEM_SIZE );
+
+
+    char test_data[ 64 ];
+
+    for ( int i = 0; i < 64; i++ )
+        test_data[ i ]  = 0xAA;
+
+    r   = iap.write_page( test_data, 241 );   //  241 is page number for sector 7 with 64 byte offset
+
+    printf( "\r\nwrite page test\r\n" );
+    printf( "write page result     = \"%s\"\r\n", r ? "FAILED" : "OK" );
+    printf( "showing memory dump to confirm 0x00003C40 to 0x00003C7F are written\r\n(should be changed to 0xAA)\r\n" );
+
+    memdump( sector_start_adress[ TARGET_SECTOR ], MEM_SIZE );
+
 #endif
 
 
@@ -164,9 +181,9 @@
     memdump( mem2, MEM_SIZE );
 #endif
 
+    printf( "Done! (=== IAP: Flash memory writing test ===)\r\n\r\n" );
 }
 
-
 #include    <ctype.h>
 
 void memdump( char *base, int n )