Juha-Matti Koopikka

S12XDP512 non-banked FLASH

Discussion created by Juha-Matti Koopikka on Jan 15, 2008
Latest reply on Jan 17, 2008 by Juha-Matti Koopikka

I have had some trouble to write data to FLASH. The destination of catched data is in ROM_4000 and it lies in non-banked area. The fuctions that i use to write data works fine, if I use paged Flash. But this memory are is not good if I want to make bootloader for this device. I really don't know where to find answers to this problem.

I'm using CW for HC12 V4.6 and P&E Micro USB multilink.

the writer function looks like:

UBYTE PerformWriteWord(UDWORD Addr,UWORD Data)
     UBYTE err;
     getCCR_disI();                                  // Save CCR, disable interrupts
     FSTAT = 48;                                      // Clear PVIOL & ACERR flag

     if (FSTAT_CBEIF == 0){restoreCCR();return ERR_BUSY;} // Is command buffer full ?
     *(UWORD *far) Addr = Data;                       // Array address and program data
     FCMD = 0x20;                                     // Word program command
     FSTAT = 0x80;                                    // Clear flag command buffer empty
     asm CLRB;                                        // Jump to Wait in RAM code
     asm JSR WaitForFlash;
     asm STAB err;

     restoreCCR();                                    // Restore CCR
     if (err) return ERR_NOTAVAIL;                    // if error return error code
     if (*(UWORD *far) Addr != Data) return ERR_VALUE;// Check written data
     return ERR_OK;

some hints would be nice