Program Once field in [MC9S12XET256]

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Program Once field in [MC9S12XET256]

2,072件の閲覧回数
g_g1
Contributor I

Hi all,

 

I need to write a Serial Number of a device to the CPU memory. I don't want to change it in the future so it would be the best to use Program Once field placed at 0x400100 address but I'm not albe to write there anything.
If I set PGMIFRON bit in the MMCCTL1 register and then try writing under the Program Once field address via far pointer I'm getting ILLEGAL_BP in HiWave.
I've tried using debugger commands but all i'm getting is "Error: error while writing to the memory".
Could someone please give me a simple step by step instruction how can I do this?

 

Best regards

ラベル(1)
0 件の賞賛
返信
4 返答(返信)

1,369件の閲覧回数
lama
NXP TechSupport
NXP TechSupport

hi,

in the attachment you can find more complex code which checks, reads and writes the field.

Just go to main function and the program flow will lead you.

If you have any doubt just ask.

Best regards,

Ladislav

1,369件の閲覧回数
g_g1
Contributor I

Thank you for your answer. I will check your code, and in case of problems I write to you.

0 件の賞賛
返信

1,369件の閲覧回数
g_g1
Contributor I

To answer my own question - I've worked it out. However a new problem has arosed.
I used CCOBIX and FCCOB registers (all listed below) to launch Program Once command.
Everythings looks good, memory is written but after this operation I'm getting an ILLEGAL_BP and processor goes to the reset.
How can I solve this problem?

//    COPCTL = 0x0u; // disable COP (Computer Operating Properly) watchdog [is it required?]
//    FCLKDIV = 0x05u; // clock divider = 5 (4 MHz) [is it required?]
    FSTAT = 0x30u; // clear any error flags

    FCCOBIX = 0x0u; // CCOBIX = 0
    FCCOBHI = 0x07u; // load Program Once command
    FCCOBLO = 0x0u;

    FCCOBIX = 0x1u; // CCOBIX = 1
    FCCOBHI = 0x0u; // load Program Once phrase index
    FCCOBLO = 0x0u; // load Program Once phrase index

    FCCOBIX = 0x2u; // CCOBIX = 2
    FCCOBHI = 0xDEu; // load Program Once word 0 value
    FCCOBLO = 0xAD; // load Program Once word 0 value

    FCCOBIX = 0x3u; // CCOBIX = 3
    FCCOBHI = 0xBEu; // load Program Once word 1 value
    FCCOBLO = 0xEFu; // load Program Once word 1 value

    FCCOBIX = 0x4u; // CCOBIX = 4
    FCCOBHI = 0xDEu; // load Program Once word 2 value
    FCCOBLO = 0xADu; // load Program Once word 2 value

    FCCOBIX = 0x5u; // CCOBIX = 5
    FCCOBHI = 0xCAu; // load Program Once word 3 value
    FCCOBLO = 0xFEu; // load Program Once word 3 value

    FSTAT = 0x80u; // launch command

Best regards,

g g

0 件の賞賛
返信

1,369件の閲覧回数
gordondoughman
Contributor III

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

0 件の賞賛
返信