gg,
The issue here is that when programming the "Write Once" field, the program memory becomes in accessible. That is, it is the same issue as if you had tried to program the PFlash block. In order to program the "Write Once" field, the code that launches the "WriteOnce" command and waits for it to complete must execute from RAM. In fact, even when reading the "Write Once" field, the code must execute from RAM.
Here is a code snippet I used:
/*************************************************************************************/
static void near LaunchFCCOBCmd(void)
{
DisableInterrupts;
FSTAT = 0x80;
while ((FSTAT & 0x80) == 0)
;
EnableInterrupts;
}
/*************************************************************************************/
static void near LaunchFCCOBCmdEnd(void)
{
}
/*************************************************************************************/
static ErrorNum GetProgramOnceData(char *ROData)
{
/* Variable Declarations */
uchar StackCode[32];
uint x, CodeLen;
uchar *CodeByteP;
void (* near LaunchCmd)(void) = (void *)StackCode; /* initialize the function pointer to point to the code we'll copy onto the stack */
/* Begin Function GetProgramOnceData() */
CodeLen = (uint)((uchar *)LaunchFCCOBCmdEnd - (uchar *)LaunchFCCOBCmd); /* Get the size of the code */
CodeByteP = (uchar *)LaunchFCCOBCmd; /* init pointer to the code we'll copy */
for (x = 0; x < CodeLen; x++) /* copy code onto the stack, one byte at a time */
StackCode[x] = *CodeByteP++;
.
.
.
Hope this helps.
Best Regards,
Gordon