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:
5:806960ca964e
Parent:
4:5705a494169a
Child:
6:2357a04a16ff
diff -r 5705a494169a -r 806960ca964e main.cpp
--- a/main.cpp	Tue Jan 13 09:11:47 2015 +0000
+++ b/main.cpp	Fri Jan 16 08:00:33 2015 +0000
@@ -40,8 +40,9 @@
  *        revision 2.0  26-Nov.2012   LPC11U24 code added
  *        revision 2.1  26-Nov-2012   EEPROM access code imported from Suga koubou san's (http://mbed.org/users/okini3939/) library
  *                                            http://mbed.org/users/okini3939/code/M0_EEPROM_test/
- *        revision 3.0  09-Jan-2014   LPC812 and LPC824 support added
- *        revision 3.1  13-Jan-2014   LPC1114 support added
+ *        revision 3.0  09-Jan-2015   LPC812 and LPC824 support added
+ *        revision 3.1  13-Jan-2015   LPC1114 support added
+ *        revision 3.1.1 16-Jan-2015  Target MCU name changed for better compatibility across the platforms
  */
 
 #include    "mbed.h"
@@ -49,13 +50,13 @@
 
 #define     MEM_SIZE        256
 
-#if defined(TARGET_LPC1768)
+#if defined(TARGET_LPC176X)
 #define     TARGET_SECTOR    29     //  use sector 29 as target sector if it is on LPC1768
-#elif defined(TARGET_LPC11U24) || defined(TARGET_LPC1114)
+#elif defined(TARGET_LPC11UXX) || defined(TARGET_LPC11XX)
 #define     TARGET_SECTOR    7      //  use sector  7 as target sector if it is on LPC11U24
 #define     TARGET_EEPROM_ADDRESS   64
 #define     TARGET_EEPROM_ADDRESS   64
-#elif defined(TARGET_LPC812) || defined(TARGET_LPC824)
+#elif defined(TARGET_LPC81X) || defined(TARGET_LPC82X)
 #define     TARGET_SECTOR    15      //  use sector  15 as target sector if it is on LPC812
 #endif
 
@@ -122,7 +123,7 @@
     memdump( sector_start_adress[ TARGET_SECTOR ], MEM_SIZE * 3 );
 
 
-#if defined(TARGET_LPC812) || defined(TARGET_LPC824)
+#if defined(TARGET_LPC81X) || defined(TARGET_LPC82X)
     iap.prepare( TARGET_SECTOR, TARGET_SECTOR );
     r   = iap.erase_page( 241, 241 );   //  241 is page number for sector 7 with 64 byte offset
 
@@ -134,7 +135,7 @@
 #endif
 
 
-#if defined(TARGET_LPC11U24)    //  SAMPLE OF EEPROM ACCESS (LPC11U24 only)
+#if defined(TARGET_LPC11UXX)    //  SAMPLE OF EEPROM ACCESS (LPC11U24 only)
     printf( "IAP: EEPROM writing test\r\n" );
     char    mem2[ MEM_SIZE ];