Flash Access Error Flag when running FTFE flash erase command on K60.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flash Access Error Flag when running FTFE flash erase command on K60.

1,304 Views
boci
Contributor II

Hello,

I wrote a flash driver and it works fine  on K70 cpus .

Flash erase works fine and flash programming works fine.

Flash erase starts from address 0x20000 and goes to the end of the flash (1MB for K70) erasing 4kB sector at the time.

However, same code, on K60 cpu, does not work.

When first flash sector erase command is invoked to start erasing from address 0x20000 I get Flash Access Error Flag.

Strange thing is that if I break (breakpoint, IAR) before erase command is invoked, than erase command runs successfully.

What could be causing this? Does anyone have any idea?

I appreciate any help.

Labels (1)
0 Kudos
4 Replies

732 Views
boci
Contributor II

Update.

So I found out that on K60, the FTFE_FCCOB registers are not being set correctly.

If I break before the registers are to be set and step through it than the registers get set correctly.

If I break after registers are being set than they are set incorrectly and thus the Flash Access Error Flag .

What could be causing this?

Here is the code that sets the registers.  'startAddress' is the address that I am passing.

*(volatile uint8_t *)&FTFE_FCCOB0 = (uint8_t)FLASH_CMD_SECTOR_ERASE;

*(volatile uint8_t *)&FTFE_FCCOB1 = (uint8_t)(startAddress >> 16);

*(volatile uint8_t *)&FTFE_FCCOB2 = (uint8_t)((startAddress >> 8) & 0xFF);

*(volatile uint8_t *)&FTFE_FCCOB3 = (uint8_t)(startAddress & 0xFF);

Any help would be great.

0 Kudos

732 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Boci Nik:

What is the full part number of your K60? And the mask (below part number)?

That behavior sounds very strange. If possible please attach your project so I can give it a check from my side.

Regards!

Jorge Gonzalez

0 Kudos

732 Views
boci
Contributor II

Hello Jorge,

Thank you very much for replying and offering help.

Here is the full part number for K60 CPU -  MK60FX512VLQ12 .  The code in the message above does NOT work with this CPU.

However, the same code works on K70 CPU, part number MK70FN1M0VMJ12.

So, to make it work on K60 also, I put in while loops. Here is the modified code that works on both CPUs.

If you guys can explain why I need this for K60, that would be great. I curious to know what is the reason.

    while(FTFE_FCCOB0 !=(uint8_t)FLASH_CMD_SECTOR_ERASE)

    {

      *(volatile uint8_t *)&FTFE_FCCOB0 = (uint8_t)FLASH_CMD_SECTOR_ERASE;

    }

    while(FTFE_FCCOB1 != (uint8_t)(startAddress >> 16))

    {

      *(volatile uint8_t *)&FTFE_FCCOB1 = (uint8_t)(startAddress >> 16);

    }

    while(FTFE_FCCOB2 != (uint8_t)((startAddress >> 8) & 0xFF))

    {

      *(volatile uint8_t *)&FTFE_FCCOB2 = (uint8_t)((startAddress >> 8) & 0xFF);

    }

    while(FTFE_FCCOB3 != (uint8_t)(startAddress & 0xFF))

    {

      *(volatile uint8_t *)&FTFE_FCCOB3 = (uint8_t)(startAddress & 0xFF);

    }

0 Kudos

732 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Boci Nik:

I have never seen such issue before, but I wonder if it is caused by a memory serialization problem. See the next document about this:

Serialization of memory operations and events

Then instead of a while loop you can try with a simple read from the FCCOBx registers AFTER each write instruction.

Regards!

Jorge Gonzalez

0 Kudos