cancel
Showing results for 
Search instead for 
Did you mean: 

ST10F276 soft in IFLASH, data in XFLASH, not clear XFLASH

p-alain
Associate II
Posted on October 31, 2006 at 13:19

ST10F276 soft in IFLASH, data in XFLASH, not clear XFLASH

21 REPLIES 21
p-alain
Associate II
Posted on July 12, 2005 at 07:09

Hello,

I work with Keil and ST10F276.

I would like to store the bigger part of my soft in IFLASH and to locate some variables in XFLASH. During the reser, I would like to not clear the variables store in XFLASH to be able to read this variables.

Is it possible. thank you.

najoua
Associate II
Posted on July 12, 2005 at 07:32

Hi,

Yes of course you can read your variables stored in XFLASH even after reset because the XFLASH has the same characteristics as the Internal Flash (Data are not lost after reset or power loss...).

Regards,

p-alain
Associate II
Posted on July 12, 2005 at 09:28

OK, but what i want to do is the following. during the execution of the programm, i would like to store some data in xflash (for exemple the number of boot of the st10), and i would like to be able read i after a reset.

charles239955_st
Associate II
Posted on July 13, 2005 at 08:21

Hello,

Yes it is possible. Basically you need to have inside your application some Flash drivers in order to write to the Flash.

Before going into reset you launch a procedure to write the Data you need into the XFlash. The main issue is to not erase. The Flash is not like and EEPROM: you need to erase a full sector even if there is only 1 location you need to clear.

But you can write to virgin location without erasing before.

So I see 2 ways.

1/ If it is a set of variable you have to store in XFlash.

At each write you change the location of the data you need to save. Lets say you have 32 bytes of saving_data. If you have a full 64K sector available it give you 2K operations.

At each reset you browse the sector until you find the 1st virgin location and your last set of saving_data starts 32 bytes before.

After 2K operations, you will need to perform an erase operation.

2/ If it is more like counters (number of boot)

Then you could using ''bit ticking''. Flash location are virgin at FFFFh. Write operations are able to put a single cell to value 0 instead of 1.

So you could implement your counter by using several location (depending on the count range you need and the available size of Flash) and clear 1 bit at each reset.

So FFFFh is the default, FFFEh = 1 reboot, FFFCh = 2 reboot, FFF8h...

But I would say that in any case, it may requires that a big part of XFlash is available for this. So it migth be that you will have anyway to perform a reset operation. But not every time.

I hope this helps.

p-alain
Associate II
Posted on July 13, 2005 at 10:30

Hello,

I think that the best way for me is the first one you said.

Do you think that i could find the Flash driver from Keil ?

I need to have the sector erase driver, and the data save driver.

Thank you.

najoua
Associate II
Posted on July 15, 2005 at 05:06

Hello Pierrot,

A flash library supported by TASKING and Keil toolchains will be provided by ST.

Find below a routine for programming a data in the Flash (IFLASH or XFLASH) and another for erasing a sector in the bank0.

//Prototypes

void SectorErase( int Block ) ;

void FlashProgram(unsigned long Address, unsigned long Data) ;

// Defines

#define FCR1L *(unsigned int huge *)0x000E0004

#define ser (unsigned int) 0x0800 /* Sector Erase*/

#define b0f0 (unsigned int) 0x0001 /* Bank0 Flash Sector 0 Status-Select */

#define MAX_IFLASH_ADDRESS (unsigned long)0x0008FFFE

#define MAX_XFLASH_ADDRESS (unsigned long)0x000DFFFE

#define Ismod (unsigned int) 0x0080

#define Xsmod (unsigned int) 0xFF7F

#define FCR0H *(_huge unsigned int *)(0x000E0002)

#define FDR0 *(_huge unsigned long *)(0x000E0008)

#define FAR *(_huge unsigned long *)(0x000E0010)

#define wpg (unsigned int) 0x2000 /* Word Program */

#define wms (unsigned int) 0x8000 /* Write Mode Start */

/************************************************************/

/* Program a single Word to the specified Flash Address */

/************************************************************/

void FlashProgram(unsigned long Address, unsigned long Data)

{

if( Address <= MAX_IFLASH_ADDRESS)

FCR0H = FCR0H | Ismod; // Set the Select Module bit to work on the IFlash

else if( Address <= MAX_XFLASH_ADDRESS )

FCR0H = FCR0H & Xsmod; // Clear the Select Module bit to work on the XFlash

if( (0x0000 <= Address) & (Address

{

Address = Address | 0x00010000; // When programming we must have the address in segment 1

}

FCR0H = FCR0H | wpg; // Set the Word Programming Bit

FAR = Address; // Load the Address

FDR0 = Data; // Load the Data

FCR0H = FCR0H | wms; // Set the Write Mode Start Bit

}

/******************************************************************************/

// Erase the specified Flash Sector in Bank0

/******************************************************************************/

void SectorErase( int Block )

{

FCR0H = FCR0H | Ismod; // Set the Select Module bit to work on the IFlash

FCR0H = FCR0H | ser; // Set the Sector Erase Bit

FCR1L = FCR1L | (b0f0 << Block); // Set the specified Bank Status Bit

FCR0H = FCR0H | wms; // Set the Write Mode Start Bit

}

main()

{

SectorErase(0);

FlashProgram( 0x10008,0x2598DB0);

}

I hope this helps you.

michaelgaus9
Associate II
Posted on September 02, 2005 at 11:49

Hello,

unfortunately, there is no example for the polling routine for waiting of the completion of the erase and programming routine.

Could you please give an example?

Thanks.

michaelgaus9
Associate II
Posted on September 03, 2005 at 12:58

Hello,

could you please explain the BER and MER bits?

I can't find them in the datasheet...

Thanks.

graziano
Associate II
Posted on October 18, 2005 at 07:02

We tried the provided example on a ST10F272 but we aren't able to write anything on the flash. Is the example suitable for that MCU ? Is any modification to add ? Thanx in advance

Graziano