cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F3 EEPROM Emulation -> HardFault

s61331
Associate II
Posted on February 06, 2017 at 16:06

Hello,

i try to implement the EEPROM Emulation for the F3 to my Motor Control Application.

But in

EE_Init()

after

PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS);

i get a Hardwarefault.

I added the Files eeprom.c and eeprom.h from here:

http://www.st.com/en/embedded-software/stsw-stm32112.html

 

to my project.

The Flash is unlocked in main.c before EE_Init();

I work with IAR EWARM

i hope someone can help me.

5 REPLIES 5
Posted on February 06, 2017 at 17:32

Is it by chance erasing memory you are currently executing from? You should try to avoid doing that.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
s61331
Associate II
Posted on February 07, 2017 at 08:57

Hello Clive,

i think the memory is not erased at all.

in Main.c

Init GPIO, USART,SPI....

...

/* Unlock the Flash Program Erase controller */

    FLASH_Unlock();

    

    printf('Flash unlocked\r\n');

/* EEPROM Init */

    //EE_Init();

    printf('EE Inited\r\n');

    

    EE_WriteVariable(VirtAddVarTab[0], VarValue1);

    

    EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);

...

And in eeprom.c

uint16_t EE_Init(void)

{

  uint16_t PageStatus0 = 6, PageStatus1 = 6;

  uint16_t VarIdx = 0;

  uint16_t EepromStatus = 0, ReadStatus = 0;

  int16_t x = -1;

  uint16_t  FlashStatus;

  /* Get Page0 status */

  PageStatus0 = (*(__IO uint16_t*)PAGE0_BASE_ADDRESS); -> After this Command a get the Hard Fault

  /* Get Page1 status */

  PageStatus1 = (*(__IO uint16_t*)PAGE1_BASE_ADDRESS);

....

So, i think the memory is not erased. It just check the value of Page0 Start Address.

The Flash is empty (FFFFFFFF) from Address 0x08009AB0

/* EEPROM start address in Flash */

#define EEPROM_START_ADDRESS    ((uint32_t)0x08010000) /* EEPROM emulation start address:

                                                  after 64KByte of used Flash memory */

/* Pages 0 and 1 base and end addresses */

#define PAGE0_BASE_ADDRESS      ((uint32_t)(EEPROM_START_ADDRESS + 0x000))

The ST-Link Utility cant read memory at 0x08010000......

Start Address to high?

Which Address would it be ok? 0x0800FF00 doesnt work.

s61331
Associate II
Posted on February 07, 2017 at 10:29

I have found the fault....

0x08010000 - Page Size = 0x0800F800 = Start Address

and i changed the End Address of the ROM in the Linker options to 0x0800F7FF

Posted on February 07, 2017 at 17:15

I guess the real question would be which STM32F3xx part specifically are you using, and how much FLASH it is supposed to come with.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
s61331
Associate II
Posted on February 08, 2017 at 08:44

Hello Clive,

its a STM32F302C8T6

so it should have 64kb Flash (0x08000000 to 0x0800FFFF) and a page size of 2kb (0x800)