David Kelly

FSTAT_BLANK bit in FSTAT on S12NE64?

Discussion created by David Kelly on Jun 20, 2008
Latest reply on Jun 30, 2008 by David Kelly
I don't see any errata on this, but am also not seeing any example code using FSTAT_BLANK.

This code is located in RAM and issues commands to the FLASH system:

#pragma MESSAGE DISABLE C12002
static void near
ram_flash_cmd( UINT08 cmd, UINT08 page, UINT16 *address, UINT16 data )
{
UINT08 old_page; // don't know if this is important to save

_RESET_COP_();

// clear access and protection bits
FSTAT = ( FSTAT_ACCERR_MASK | FSTAT_PVIOL_MASK );

old_page = PPAGE; // save
PPAGE = page; // set
*address = data; // Sets data and address for FLASH state machine
FCMD = cmd;
FSTAT_CBEIF = 1; // start FLASH command execution

nop();
nop();
nop();

while( FSTAT_CBEIF != 1 ) // infinite loop until set
;

if( FSTAT & ( FSTAT_ACCERR_MASK | FSTAT_PVIOL_MASK ) )
ram_errno = 10;

PPAGE = old_page; // restore
}
#pragma MESSAGE DEFAULT C12002

When called ram_flash_cmd( 0x05, 0x3e, 0x8000, 0xffff ) to check the blank status FSTAT returns containing 0xC2, bit 1 is set. Manuals and #include files say bit 2 (mask 0x04) is the one we are looking for. Having previously called this routine with cmd = 0x40 I would expect the area to be erased, and looking with the memory window in the debugger confirms the apparent erased state. In all references bit 2 is undefined, said to always read as 0.

Is this an error in documentation? My chip's mask? Debugger anomaly? Or a caffeine deficiency?

Outcomes