P-flash Erase Error

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
445件の閲覧回数
kuksu
Contributor II

Hello, I am working on a Bootloader project using CAN communication with MC9S12XS64.

We are currently using interrupts for CAN and are working on a project using Process expert.

For my next flash programming task, I tested the XS series' P flash example code and my code that applied it.

Code:

------------------------------------------------------------------------

UINT8 PFlash_EraseSector(UINT32 address)
{
while((FSTAT & FSTAT_CCIF_MASK) == 0); //wait if command in progress
FSTAT = 0x30; //clear ACCERR and PVIOL

FCCOBIX = 0x00;
FCCOB = 0x0A00 | ((address & 0x007F0000)>>16);

FCCOBIX = 0x01;
FCCOB = (address & 0x0000FFF8);

FSTAT = 0x80; //launch command
while((FSTAT & FSTAT_CCIF_MASK) == 0); //wait for done

if((FSTAT & (FSTAT_ACCERR_MASK | FSTAT_FPVIOL_MASK)) != 0) 
 return FlashEraseError;
else
 return noErr;
}


UINT8 PFlash_EraseSectorBySector(UINT32 addr_l, UINT32 addr_h)
{
UINT32 Address;
UINT8 Error;

for(Address = addr_l; Address < addr_h; Address += FLASH_SECTOR_SIZE)
{
Error = PFlash_EraseSector(Address);
if(Error != noErr)
return(Error);
}
return(noErr);
}

void Memory_Write(void)
{
if(u8BootPhraseRcvd == 1) // If a complete booth phrase was received
{
u8BootPhraseRcvd = 0;

if(Verify_Phrase_Checksum()) // Check that phrase checksum matches
{

if(!u8flashErased) // the flash hasn't been erased, erase it
{
PFlash_EraseSectorBySector(0x7F0000, 0x7FEFDF); // Jump to RAM and Erase Flash, return to Flash when done.
u8flashErased = 1; //Indicate that flash has been erased

} ..... ellipsis .....

---------------------------------------------------------------------

The code compiles fine.
Debug and run in hiwave.
When the specified CAN msg is sent and the requirements are met,

PFlash_EraseSectorBySector (0x7F0000, 0x7FEFDFUL) is executed.

Afterwards, the results were confirmed through real-time debugging in hiwave.
FlashEraseError occurs in the error checking code of the example code.

During PFlash_EraseSector(UINT32 address)

FSTAT = 0x80; //launch command
while((FSTAT & FSTAT_CCIF_MASK) == 0); //wait for done

If I run the code without it, it runs without an error, but I don't know if this is correct.

I'd like to know what the problem is and how to make it work properly.

 
タグ(1)
0 件の賞賛
返信
1 解決策
426件の閲覧回数
lama
NXP TechSupport
NXP TechSupport

Hi,

The problem can be placement of the code

FSTAT = 0x80; //launch command
while((FSTAT & FSTAT_CCIF_MASK) == 0); //wait for done

 

The code is not allowed to be executed out of the memory which is erased of written.

This part of the code should be in different memory or memory block, for example,  the RAM or somewhere else.

Attached is the example.

Search for text

//==============================================================================

//PFLASH Send_Command

//==============================================================================

In the main.c module.

 

Best regards,

Ladislav

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
427件の閲覧回数
lama
NXP TechSupport
NXP TechSupport

Hi,

The problem can be placement of the code

FSTAT = 0x80; //launch command
while((FSTAT & FSTAT_CCIF_MASK) == 0); //wait for done

 

The code is not allowed to be executed out of the memory which is erased of written.

This part of the code should be in different memory or memory block, for example,  the RAM or somewhere else.

Attached is the example.

Search for text

//==============================================================================

//PFLASH Send_Command

//==============================================================================

In the main.c module.

 

Best regards,

Ladislav

0 件の賞賛
返信