Dear All,
I'm using S12P micro in my one of project. I'm using D_Flash for const variables storing. I've written following code
sCHAR flashCommand(void)
{
volatile uCHAR i;
// Check whethere previous command is still executing
while(!FLAG_COMMAND_COMPLETE);
// if there is any error then clear it
if((!FLASH_STATUS_REG1) || (!FLASH_STATUS_REG2))
{
FLASH_STATUS_REG1 = 0x30; // Clear ACCERR and FPVIOL
FLASH_STATUS_REG2 = 0x03; // Clear bit Errors
}
for(i=0; i<=indexCommandArray; i++)
{
FCCOBIX = i;
FCCOB = flashCommandArray[i];
}
FSTAT = 0x80; // Launch the command
asm nop;
asm nop;
asm nop;
asm nop;
asm nop;
asm nop;
while(!FLAG_COMMAND_COMPLETE);
return ERR_OK;
}
/****************************************************************************/
#pragma DATA_SEG DFLASH_DATA
uINT __far testString = 0x1234;
#pragma DATA_SEG DEFAULT
The DFlash is defined as,
DFLASH_00 = READ_ONLY 0x010400 TO 0x0113FF;
And calling the function by,
applyFlashCommand((uLONG) testString, 100, PROGRAM_D_FLASH);
when I execute above function, I got ACCERR everytime. As per ref manual the ACCERR will come when,
Set if CCOBIX[2:0] < 010 at command launch -- Confirmed
Set if CCOBIX[2:0] > 101 at command launch -- Confirmed
Set if command not available in current mode (see Table 13-27) - Confirmed
Set if an invalid global address [17:0] is supplied -- NOT Confirmed
Set if a misaligned word address is supplied (global address [0] != 0) -- NOT Confirmed
Set if the requested group of words breaches the end of the D-Flash block - Confirmed
Plz throw some light over this issue. I also confused that the DFlash address is logical or global(physical).
-- Thanks and Regards,
N. K. Gavali