MC56F84769: Problem with reading from P-Flash after writing

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

MC56F84769: Problem with reading from P-Flash after writing

679 Views
willihoffmann
Contributor I

Installed Products:

- CodeWarrior for MCU

     Version: 10.6

     Build Id:140329

 

Hello,

 

I have a peculiar problem with reading from P-Flash after writing to it.

 

First I write S-Records to P-Flash using simple "program longword" command and also verify that the writing succeeded using "program check" command. After writing of every S-Record I invalidate the cache and try to calculate a checksum over the written bytes, wich I then compare against the actual checksum of the written S-Record. I use the following code to invalidate the cache:

 

#define main_discard_flash_cache FMC_PFB0CR |= FMC_PFB0CR_CINV_WAY; \

                                 FMC_PFB0CR |= FMC_PFB0CR_S_B_INV;

 

I set all of the CINV_WAY bits and the S_B_INV bit.

 

This works great for the first 4 S-Records, but for all of others I fail to verify the checksum.

 

The peculiar part is that when I run the application in the debugger and put a breakpoint after the flash write and before the checksum calculation and just click "Resume" after the breakpoint triggered, then the checksum verification works correctly. The calculated value is also correct when I check in the debugger.

 

The firmware that I flashed also works perfectly fine. It's just the software verification that doesn't seem to work without debugger intervention.

 

So do I maybe have to do anything else to invalidate the flash? What does the debugger do with the flash when it halts the device?

 

- Willi

Labels (1)
0 Kudos
1 Reply

493 Views
willihoffmann
Contributor I

Ok, I solved the problem, by deleting the lowest 5 bits of FMC_PFB0CR, so I don't use cache at all.

Still I don't understand why it's not enough to invalidate the cache. It'd be nice, if someone could clarify.

0 Kudos