What is the value for length? I am sorry but I didnt find any definition for it. and after I review the flash driver you provided, I found you are using the phase access method, which program the flash with 8 byte once, that is correct as the length is 256 bytes less than the sector size, but in the implemenation, the flash command is for section program, have you modified the flash driver from www.freescale.com? I think that is why you found it wrote beyond 256 bytes.
/********************************************************
* Function for Programming of one section (maximum is 2048 Bytes)
*
********************************************************/
Byte FTFL_ProgramSectionPhrases(LWord destination, LWord* pSource, LWord size)
{
// LWord* pProgBuff = &programbuffer[0];
LWord* pProgBuff;
LWord my_size;
(unsigned long*)pProgBuff = (unsigned long*)0x14000000;
// pProgBuff = &programbuffer[0];
// check the size of memory
if(size >= sizeof(programbuffer))
return FTFL_FAIL;
if(destination & 0x00000003)
return FTFL_FAIL;
if(destination & 0x00000004)
{
if(!FTFL_ProgramLongWord(destination, *pSource++))
return FTFL_FAIL;
size--;
destination += 4;
}
my_size = size & 0xFFFFFFFE;
if(my_size)
{
/* preparing passing parameter to program the flash block */
CommandObj.regsLong.fccob3210 = destination;
CommandObj.regs.fccob0 = FTFL_PROGRAM_SECTION;
CommandObj.regs.fccob4 = (Byte)(size >> 9);
CommandObj.regs.fccob5 = (Byte)((size >> 1) & 0xff);
destination += 4* my_size;
// copy source data to program buffer
while(my_size--)
*pProgBuff++ = *pSource++;
// call flash sequence
ret_val = FTFL_FlashCommandSequence(PROGRAM_SECTION_INDEX);
if(ret_val == 0)
return FTFL_FAIL;
else if(ret_val == FLASH_WRITE_ERROR)
return FLASH_WRITE_ERROR;
else {}
}
if(size & 0x00000001)
if(!FTFL_ProgramLongWord(destination, *pSource))
return FTFL_FAIL;
return 1;
}
Have a great day,
Kan
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------