Flash not erasing

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

Flash not erasing

1,222 Views
sebasira
Senior Contributor I

Hello, everydoby!

 

After correcting some problems relating to FLASH clock, we're now having a problem... The first time (after downloading the code) the flash is not erased, all the other times it works perfectly fine.

 

We're working with HCS12 and CW4.6

 

If someone could take a look at that, it would be very helpful. We're stuck here!

 

Thanks in advance, best regards!

Labels (1)
0 Kudos
Reply
9 Replies

745 Views
sebasira
Senior Contributor I

Can anyone explain me why if I change the previous project .ini file for this one (attached) then the flash erase works perfectly fine??

 

Thanks to you all!! It's driving me crazy!

0 Kudos
Reply

745 Views
kef
Specialist I

*.ini file can't affect execution of your code. Probably you missed the fact that by default CW debugger caches contents of read only memories! Flash erase may work, but you won't see it via memory component, unless you edit debugger memory map to make flash updated from device memory.

0 Kudos
Reply

745 Views
sebasira
Senior Contributor I

Lundin:

- Maybe this is an old project which you have ported to newer versions of Codewarrior? The .CMD files were used in earlier versions, I believe they are obsolete nowadays. Have you tried to create a completely new project, then add the source files (and .PRM file) to that project?

I have already made a new project (severals) and I keep having the same problem. But when I change the .ini file flash is erase and written

 

- Maybe you have the wrong derivate specified somehow. The different S12 derivates have somewhat different flash. Have you tried to program the MCU with Cyclone Pro stand-alone, by creating a load file out of the binaries? (.s19 / .phy)

The derivate is ok, the MCU is MC9S12A256B and that's what I choose in the project wizard. I haven't try your suggestion of loading

 

 

Kef:

What you say was my first guess.... But I dismissed that when I realize that flash routine was throwing the error "FLASH_NOT_ERASED" when try to progam it.

 

 

EDIT:

I forgot to say that the error was trown only the first time I run it, after downloading the code... All the following times I run it (previously reset) the flash is erased and written. No error is trown and I can see the values written in the memory component

0 Kudos
Reply

745 Views
sebasira
Senior Contributor I

Hello again!

 

I know this is old, but this same problem happened again to me... I was so angry!!! So I decided to figure out why the same project erase the flash when loaded with a certain .ini file and won't erase it if I use another. I copy line by line from one ini file to the other, until the error was gone.

 

So this line is the problem:

DMM_MCUID03CA_MODULE0=Default£memory£block 0x0 0x10000 100 5 0 1 1 1

 

If this line is missing in my ini file, then it won't erase flash

 

why????

 

I'm working with MC9S12A256B and CW4.6

 

I'll attach a file with this line and the same without it. Just in case is not really that an it's related to something else

 

I hope someone can explain this to me! Thanks in advance!

0 Kudos
Reply

745 Views
kef
Specialist I

CW5.1 ini doesn't have such DMM... string, but instead it has

 

MCUId=XXX

 

and

 

NV_PARAMETER_FILE=C:\Freescale\CWS12v5.1\prog\FPP\mcuXXXX.fpp

 

, where XXX defines selected derivative. Derivative can be changed via multilink menu. Maybe you got ini file from CW5 project?

Is there Select Derivative... menu under USB Multilink menu in debugger? If so, then it may help if you select derivative here. Also try changing derivative to some other derivative, and then back to your derivative. It may fix ini file without the need to edit it.

0 Kudos
Reply

745 Views
sebasira
Senior Contributor I

Hello kef! Thank you for your reply

 

My .ini file also have those lines you mentioned. Same in both, the ini file that erase the flash and the one that does not.

 

MCUId=0x3CA

NV_PARAMETER_FILE=D:\Archivos de programa\Freescale\Codewarrior for HC12 V4.6\prog\FPP\mcu03CA.fpp

 

 

What drives me crazy is why would INI FILE has anything to do with flash erasing? Because as said in a post above is not a matter of visualization in the debugger, the flash routine does throw the error FLASH_NOT_ERASED when trying to re-progamm it (after the erase that somehow didn't work)

0 Kudos
Reply

745 Views
kef
Specialist I

Ah, I thought you have problem flashing code to target. I don't know why (yet), but is it your latest flash.c version? Because I see obvious bug in FLASH_ini16MHz().

 

     FCLKDIV_FDIV = 0x09;                // 0b001001 valor sugerido para 16MHz en DataSheet

      FCLKDIV_PRDIV8 = 1;                 // Habilito divisor x8 sugerido para 16MHz en DataSheet

 

You can't do these steps in separate writes. FCLKDIV is write once register in normal modes. This code may work OK with debugger and FCLKDIV may read as 0xC9, but without debugger, in normal mode only FDIV bits will be set and FCLKDIV will read as 0x89, which is bad.

0 Kudos
Reply

745 Views
sebasira
Senior Contributor I

Thanks kef!! I've corrected that!

0 Kudos
Reply

745 Views
Lundin
Senior Contributor IV

I can only guess:

 

- Maybe this is an old project which you have ported to newer versions of Codewarrior? The .CMD files were used in earlier versions, I believe they are obsolete nowadays. Have you tried to create a completely new project, then add the source files (and .PRM file) to that project?

 

- Maybe you have the wrong derivate specified somehow. The different S12 derivates have somewhat different flash. Have you tried to program the MCU with Cyclone Pro stand-alone, by creating a load file out of the binaries? (.s19 / .phy)

 

0 Kudos
Reply