cancel
Showing results for 
Search instead for 
Did you mean: 

F276 10ER when programming IFlash

diane
Associate II
Posted on November 26, 2007 at 19:12

F276 10ER when programming IFlash

7 REPLIES 7
diane
Associate II
Posted on November 13, 2007 at 19:04

I am working on a bootloader to program a hex file into Flash. The bootloader is written for the ST10F276 using Keil. I erase all XFlash and IFlash (except block 0 of bank 0, because that contains the bootloader) and confirm that it is erased by looking at the FER and using the FlashBankBlankCheck function from the ST10 C library. I then start to program, but I get a 'program 1 over 0' error in the FER. I can then go back and successfully erase the Flash again, but if I attempt to program after the second erase, I get the same error in the same place in the Flash. The address where the error occurs differs based on which hex file I am attempting to program into the Flash. Any idea what could be causing this error?

bob2
Associate II
Posted on November 14, 2007 at 07:06

When you write to the iFLASH in boot mode you have to add 0x0001'xxxx to the address you are writing to (see page 27 of the st10f276 superset manual (near table 4). This may be the problem.

Bob

diane
Associate II
Posted on November 14, 2007 at 10:43

No, I deal with the address change for reading vs. writing. Thanks for the idea, though.

najoua
Associate II
Posted on November 15, 2007 at 06:52

Hello diane.e.miller,

The '1 over 0' Error bit is automatically set when trying to program at 1 bits previously set at 0. So, I suspect the Flash is not erased well before being programmed.

Could you please read, before programming, the location where the error occurs and verify if it contains 0xFFFFFFFF or no?

Do you clear by software 10ER bit in FER register after it is set?

Could you please tell me when exactly you are reading the FER register?

In fact, the Flash error register can be properly read only once

LOCK bit of register FCR0L is low. Nevertheless, its content is updated when also BSY bits are reset as well; for this reason, it is definitively meaningful reading FER register content only when LOCK bit and all BSY bits are cleared after an operation in the Flash (write/erase).

Regards,

Najoua.

diane
Associate II
Posted on November 15, 2007 at 13:44

Hello Najoua,

Thank you for your reply. You were right, the location is not getting erased. I believe my erase function for the problematic sector of Flash follows the protocol specified by the datasheet. It is meant to erase sectors 1-9 of bank 0 of IFlash, since the bootloader is contained in sector 0. The function looks like this:

FCR0H |= 0x880;

FCR1L = 0x03FE;

FCR1H = 0;

FCR0H |= 0x8000;

while(FCR0L&0x10);

while(FCR0L&0x66);

I then check the FER and, if there are errors, I output a message and set FER = 0x0000. I then use the FlashBankBlankCheck function found in the ST10 C Flash library, which returns a 1 meaning it found all F's.

If all of this sounds like it is written properly, I think I know what the problem is but not how to solve it. In my erase function, I first erase banks 1, 2, and 3 of Flash. In order to be able to erase sectors 1-9 of bank 0, I create a copy of my bank 0 erase function at location 0x70200, which is in bank 1. I then jump to it with the following line:

((void (near *) (void)) 0x70200) ();

I believe that if the copy function or the jump were not working, then the location giving me trouble would not be erased. Do you see anything in what I've provided here which could be causing the trouble? Is there anything in particular I should look for to solve this problem?

Thank you again for your helpful response!

najoua
Associate II
Posted on November 26, 2007 at 12:18

Hello diane,

As i see, you are executing the erase routine from the flash Bank1.

Could you please try to execute it from another memory rather than the flash itself and tell me if the pb persists or no?

Regards,

Najoua.

diane
Associate II
Posted on November 26, 2007 at 19:12

I have fixed the problem; it seems that the jump to the copied function was not working, although I'm not sure why. Rather than copying the erase routine and jumping to it, I hard-coded it to bank 3 of Flash and simply called it. Now the erase and program work. Thank you for your input.