3 Replies Latest reply on Jul 31, 2018 12:15 AM by HongyanW_86

    How to write the work flash ? (CHIP model: MB9DF566)

      HI, I'm trying to write (program) the workflash in the chip MB9DF566. The code is as follows:

       

      IDE: IAR for ARM

       

      #define WFCFG_UNLOCK_CODE      0xCF6DF1A5

       

      #define WFCFG00_MA1_BASE           (0x0E000000)     // Base Addr of the workflash

       

      #define WFCFG00_UNLOCK                                             \

      {                                                                                            \

                WFCFG00_CPR = WFCFG_UNLOCK_CODE;        \

      }

       

      void Init_WorkFlash00(void)

      {

                // Program enable

                //WFCFG00_UNLOCK;

                //WFCFG00_CR_WE = 1;

       

                // Flash wait control

                WFCFG00_UNLOCK;

                WFCFG00_CR_FAWC = 2;

       

                // Enable ECC

                WFCFG00_UNLOCK;

                WFCFG00_ECR_ECCOFF = 0;

       

                // Disable DMA

                WFCFG00_WCR_DMAEN = 0;

       

                // Disable the generation of hang interrupt requests

                WFCFG00_ICR_HANGIE = 0;

       

                // Disable generation of ready interrupt requests

                WFCFG00_ICR_RDYIE = 0;

       

                // Clear interrupts

                WFCFG00_ICR_HANGIC = 1;

                WFCFG00_ICR_RDYIC = 1;

       

                // Software reset

                WFCFG00_UNLOCK;

                WFCFG00_CR_SWFRST = 1;

      }

       

       

      void WorkFlash00Write(uint32_t Addr_Offset, uint32_t Data)

      {

                uint32_t *pDes = ((uint32_t *)WFCFG00_MA1_BASE) + Addr_Offset;

       

                // Program enable

                WFCFG00_UNLOCK;

                WFCFG00_CR_WE = 1;

       

                while(0 != WFCFG00_WSR_ST);

                *pDes = Data;

                while(1 != WFCFG00_SR_RDY);

       

                // Program disable

                WFCFG00_UNLOCK;

                WFCFG00_CR_WE = 0;

      }

       

      When the code steps over the line: 

       

      *pDes = Data;

       

      the regester WFCFG00_BERR_ACCIGN  = 1, which means a command overrun, and the write operation fails.

      Then when steps over the next line, the IAR show me a dialog "Warning: Stopped at unknown breakpoint".

       

      Please help me to find the right way to write the workflash. Maybe directly access the workflash by point is not right, but I couldn't find a register which could access the workfalsh area.