-Is not the programming algo the same for 16F648 as 16F84?
-(I mean 6 bits command, 14 bits data etc.. the works? ), some
-us delay..
Never mid, I found the programming spec, BTW I did that other erase procedure for
the 12F6xx
This is a mod to noppp_lx (Linux) I did last year:
void Derase()
{
int a, i;
vppreset();// Vpp now ON!!!,
// and has been 25000 uS because of delay in vppreset.
printf("Commanding PIC to erase ID, configuration\n");
/*
From Microchip pdf
Read and store OSCCAL and BG bits
Execute Load Configuration000000
Execute Bulk Erase Program Memory001001 (will also erase data memory of !CPD was 0)
Wait Tera
Execute Bulk Erase Data Memory0010011
Wait Tera
Reset device to RESET address counter before re-programming device
Restore OSCCAL and BG bits
*/
/* read osccal from program memory 0x03ff OSCCAL in bank 1 address 0x90 */
/* move up in program address space */
i = 0;
while(1)
{
sendcmd(READPROGRAM);
a = recvdata();
if(i == 0x03ff)
{
osccal = a & 0xff; // 8 bits register */
break;
}
sendcmd(INCREMENTADDRESS);
i++;
}
fprintf(stdout, "i=0x%04x a=0x%03x osccal=0x%04x\n", i, a, osccal);
/* read bandgap bits */
sendcmd(LOADCONFIG);
// prog counter now at 0x2000
//senddata(DEFAULTCONFIG); // loadconfig requires an arg, here it is
/* read 7 words from 0x2000 up */
sendcmd(READPROGRAM);
a = recvdata();
fprintf(stdout, "CONFIG MEMORY 0x2000=0x%03x ID LOCATION\n", a);
sendcmd(INCREMENTADDRESS);
sendcmd(READPROGRAM);
a = recvdata();
fprintf(stdout, "CONFIG MEMORY 0x2001=0x%03x ID LOCATION\n", a);
sendcmd(INCREMENTADDRESS);
sendcmd(READPROGRAM);
a = recvdata();
fprintf(stdout, "CONFIG MEMORY 0x2002=0x%03x ID LOCATION\n", a);
sendcmd(INCREMENTADDRESS);
sendcmd(READPROGRAM);
a = recvdata();
fprintf(stdout, "CONFIG MEMORY 0x2003=0x%03x ID LOCATION\n", a);
sendcmd(INCREMENTADDRESS);
sendcmd(READPROGRAM);
a = recvdata();
fprintf(stdout, "CONFIG MEMORY 0x2004=0x%03x NOT USED\n", a);
sendcmd(INCREMENTADDRESS);
sendcmd(READPROGRAM);
a = recvdata();
fprintf(stdout, "CONFIG MEMORY 0x2005=0x%03x NOT USED\n", a);
sendcmd(INCREMENTADDRESS);
sendcmd(READPROGRAM);
a = recvdata();
fprintf(stdout, "CONFIG MEMORY 0x2006=0x%03x DEVICE ID (PIC12F629=0x00f4, PIC12F675=0x00f6)\n", a);
sendcmd(INCREMENTADDRESS);
sendcmd(READPROGRAM);
a = recvdata();
fprintf(stdout, "CONFIG MEMORY 0x2007=0x%03x CONFIGURATION BITS\n", a);
sendcmd(INCREMENTADDRESS);
bandgap1 = (a >> 13) & 1;
bandgap0 = (a >> 12) & 1;
fprintf(stdout, "bandgap0=%d (BG0)\n", bandgap0);
fprintf(stdout, "bandgap1=%d (BG1)\n", bandgap1);
/* erase all */
sendcmd(LOADCONFIG);
// prog counter now at 0x2000
senddata(0x3FFF);
for (i = 7; i > 0; i--) sendcmd(INCREMENTADDRESS);
sendcmd(ERASEPROGRAM);
usleep(10000);
sendcmd(ERASEDATA);
usleep(10000);
allpinslow();
fprintf(stdout, "Done.\n");
} /* end function erase */
Not sure it makes sense to you.
For what it is worth, all 12F6xx are working.
Tomorrow perhapos I will have a go with the specs I just found.
JP