Quantcast
Channel: Tools
Viewing all articles
Browse latest Browse all 91752

Forum Post: Flash programming example won't restart on power cycle

$
0
0

Santosh helped me work through the follow-on problem to my previous post about not being able to relocate flash memory and then operate successfully.

Upon further testing, I found that I was not then able to power-cycle my program and get it to run again.

In stepping through the program, Santosh found that the code for the example did not specify auto ECCGeneration, therefore, auto ECC was not a part of the replaced code. To correct this, the following canges were made to the Flash_Write routine:

 

#pragma CODE_SECTION(FlashWrite,"ramfuncs");

// write sector of data to flash, given start add and no. bytes, return status

Fapi_StatusType FlashWrite(uint32 DLoad_Address,uint8* bdat, uint8 bytes)

{

//Data/Program Buffers used for the flash API functions

/////

/////    Fapi_LibraryInfoType       oLibInfo;

 Fapi_FlashStatusType       oFlashStatus;

Fapi_StatusType oReturnCheck;

 Fapi_FlashStatusWordType   oFlashStatusWord;

uint8 i;

 uint32 u32Index = 0;

   // transfer Buffer to flash

 // A data buffer of max 16 bytes can be supplied to the program function.

 // Each word is programmed until the whole buffer is programmed or a

  // problem is found.

 // However to program more a buffer that has more than 16 bytes,

  // program function can be called in a loop to program 16 bytes for each loop

// iteration until the whole buffer is programmed

/////

oReturnCheck =Fapi_Status_Success;

// Disable ECC so that error is not generated when reading Flash

   // contents without ECC

 //HWREG(FLASH_ERROR_BASE + FLASHERR_O_ECC_ENABLE) = 0x0;  remove this

for(i=0, u32Index = DLoad_Address ;

       (u32Index < (DLoad_Address + bytes))

       && (oReturnCheck ==

Fapi_Status_Success); i+= 16, u32Index+= 16)

    {

        oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,bdat+i,

                       16,

                       0,

                       0,Fapi_AutoEccGeneration);  //changed this to AutoEcc

while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);

if(oReturnCheck != Fapi_Status_Success)

        {

 // Check Flash API documentation for possible errors

            Example_Error(oReturnCheck);

        }

// Read FMSTAT register contents to know the status of FSM after

// program command for any debug

        oFlashStatus =Fapi_getFsmStatus();

       

// Verify the values programmed.  The Program step itself does a verify

       

// as it goes.  This verify is a 2nd verification that can be done.

        oReturnCheck =Fapi_doVerifyByByte((uint8 *)u32Index,

                       16,

                       bdat+i,

                       &oFlashStatusWord);

       

if(oReturnCheck != Fapi_Status_Success)

        {

    // Check Flash API documentation for possible errors

        Example_Error(oReturnCheck);

        }

    }

return oReturnCheck;

}

Now the example will run and restart on power cycle.

Thanks again, Santosh

Pat

 


Viewing all articles
Browse latest Browse all 91752

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>