S12XEP100 / XS64 Data Flash

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S12XEP100 / XS64 Data Flash

2,429 Views
Heppell
Contributor II
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) { ; }



Labels (1)
3 Replies

421 Views
CrasyCat
Specialist III
Hello
 
How are you trying to see modified data?
Are you Using CodeWarrior debugger and trying to see modified memory in there?
 
If that is the case you need to modify the Debug memory map and tell the debugger content of a FLASH block is subject to change when application is running.
Per default the debugger considers that content of flash memory remains unchanged when application runs.
 
In order to change that:
  - Start the debugger the usual way
  - In the Target menu (Multilink/CyclonePro, inDART-HC12, ...) select "Debugging Memory Map"
  - Select the block (or blocks) of FLASH memory that you are reprogramming
  - Click on "Modify/Details"
  - Check the box "refresh memory when halting"
  - Close the dialog with OK.
 
These settings will be stored in the debug project file (.ini) and you only need to configure it once for your project.
 
I hope this helps a bit.
 
CrasyCat

421 Views
Heppell
Contributor II
Hi,

I am looking at the (global) memory using the debugger tool. I was not using this setting (thanks), I was doing a right-click and Refresh to see the up to date data. Either way, the data is unchanged.
0 Kudos

421 Views
Heppell
Contributor II
Problem Solved.

The issue was how the registers were mapped, eg FSTAT register was not pointing to the right memory location. I was using an older I/O Map file which had these issues. (A few other lines of code as shown above were causing issues, easily debugged with this new I/O Map)

By the way, I found this out after reading good materials:
AN3490 Overview of the MC9S12XE Emulated EEPROM
AN3343 Emulated EEPROM Quick Start Guide

This came with code, which allowed me to view the location of FSTAT in memory which was diffrent from my own setup.


0 Kudos