This works with the 16F84 and a few other flash parts. // --- This will erase all program and config flash memory in the part // Execute Load Config command WriteCommand(g_pChip->cmdLoadConfig); WriteData(0x7FFE); // Inc to config word location (0x2007) for(int i=0;i<7;i++) WriteCommand(g_pChip->cmdIncAddress); // Execute Erase Setup 1 WriteCommand(g_pChip->cmdBulkEraseSetup1); // Execute Erase Setup 2 WriteCommand(g_pChip->cmdBulkEraseSetup2); // Execute Begin Programming command WriteCommand(g_pChip->cmdBeginEraseProgrammingCycle); // Wait Sleep(10); // Execute Erase Setup 1 WriteCommand(g_pChip->cmdBulkEraseSetup1); // Execute Erase Setup 2 WriteCommand(g_pChip->cmdBulkEraseSetup2); // --- Erase data memory // Execute Load Config command WriteCommand(g_pChip->cmdLoadDataForDataMemory); WriteData(0x7FFE); // Execute Erase Setup 1 WriteCommand(g_pChip->cmdBulkEraseSetup1); // Execute Erase Setup 2 WriteCommand(g_pChip->cmdBulkEraseSetup2); // Execute Begin Programming command WriteCommand(g_pChip->cmdBeginEraseProgrammingCycle); // Wait Sleep(10); // Execute Erase Setup 1 WriteCommand(g_pChip->cmdBulkEraseSetup1); // Execute Erase Setup 2 WriteCommand(g_pChip->cmdBulkEraseSetup2); // Commands for 16F84 0x00, // Load Configuration 0x06, // Increment Address 0x01, // Bulk Erase Setup 1 0x07 // Bulk Erase Setup 2 0x08, // Begin Erase Programming Cycle 0x02, // Load Data for Program Memory -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads