Rene Heppell

S12XEP100 / XS64 Data Flash

Discussion created by Rene Heppell on Nov 25, 2008
Latest reply on Nov 26, 2008 by Rene Heppell
I'm having trouble programming the Data Flash, I'm developing using the S12XEP100 (Porting to XS64 later). The commands seem to be going through but I am not seeing any data being written.

The memory shows empty (FFFFF....) from 0x100000 -0x107FFF

Checking the FSTAT, FECCR registers shows no errors on commands. I'm confused as to what is going on.

Here is come code:

dfInfo.dfAddress = 0x0000;
*dfInfo.ramAddress = "text";
dfInfo.totalCount = 4;

INITIALIZATION

   FCLKDIV = 0x03;      /* 4MHz Oscillator Clock Frequency */
   /* Flash Configuration Register */
   FCNFG    = ((UINT8)(0u << 7) |  /* CCIE = 0   */
               (UINT8)(0u << 4) |  /* IGNSF = 0  */
               (UINT8)(0u << 1) |  /* FDFD = 0   */
               (UINT8)(0u << 0));  /* FSFD = 0   */
   /* Flash Error Configuration Register */
   FERCNFG  = ((UINT8)(0u << 1) |  /* DFDIE = 1    */
               (UINT8)(0u << 0));  /* SFDIE = 0    */
      EPROT |= (UINT8)(1u << 7);    /* EPOPEN = 1 */
      EPROT |= (UINT8)(1u << 3);    /* EPDIS = 1 */


ERASE SECTOR


      /* Access Error and Protection Violation Check*/
      if ( ((FSTAT & 0x10u) == 0x10u) ||        /* FPVIOL */
           ((FSTAT & 0x20u) == 0x20u) )         /* ACCERR */
      {
         FSTAT |= 0x30; /* FPVIOL = 1, ACCERR = 1 */
      }
         /* Program Command and given Instruction */
         FCCOBIX = 0x0u;       /* Instruction Step 1, chooses the FCCOB register array */
         FCCOBHI = DF_CMD_CODE_ERASE_SEC;

         /* Address Command and Data Set */
         FCCOBLO = 0x10u;                                /* Global Address [22:16] Block Info  */
         FCCOBIX = 0x1u;                                 /* Step 2 */
         FCCOBHI = (UINT8)(dfInfo.dfAddress >> 8u);      /* Global Address [15:8] Sector MSB  */
         FCCOBLO = (UINT8)(0xFF & dfInfo.dfAddress);     /* Global Address [7:0] Sector LSB   */
         dfInfo.totalCount--;
      /* Write FSTAT register to Load Command (CCIF Flag) */
      FSTAT |= (UINT8)(1u << 7);    /* CCIF = 1    */

      /* Bit Polling for Command Completion Check */
      while ((FSTAT & 0x80u) == 0u) { ; }

PROGRAM

      /* Access Error and Protection Violation Check*/
      if ( ((FSTAT & 0x10u) == 0x10u) ||        /* FPVIOL */
           ((FSTAT & 0x20u) == 0x20u) )         /* ACCERR */
      {
         FSTAT |= 0x30; /* FPVIOL = 1, ACCERR = 1 */
      }
         /* Program Command and given Instruction */
         FCCOBIX = 0x0u;       /* Instruction Step 1, chooses the FCCOB register array */
         FCCOBHI = DF_CMD_CODE_PROGRAM;

         /* Address Command and Data Set */
         FCCOBLO = 0x10u;                                /* Global Address [22:16] Block Info  */
         FCCOBIX = 0x1u;                                 /* Step 2 */
         FCCOBHI = (UINT8)(dfInfo.dfAddress >> 8u);      /* Global Address [15:8] Sector MSB  */
         FCCOBLO = (UINT8)(0xFF & dfInfo.dfAddress);     /* Global Address [7:0] Sector LSB   */

         /* Data Commands and Data Words (up to 8 bytes being written) */
         while (counter < 8u && dfInfo.totalCount > 0u)
         {
            if ((counter % 2u) == 0u) { FCCOBIX = (counter/2u)+2u; } /* FCCOBIX = 2,3,4,5 */
            FCCOBLO = *dfInfo.ramAddress;
            dfInfo.totalCount--;
            dfInfo.ramAddress++;
            counter++;
         }
      /* Write FSTAT register to Load Command (CCIF Flag) */
      FSTAT |= (UINT8)(1u << 7);    /* CCIF = 1    */

      /* Bit Polling for Command Completion Check */
      while ((FSTAT & 0x80u) == 0u) { ; }



Outcomes