2017-02-06 07:06 AM
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.
2017-02-06 08:32 AM
Is it by chance erasing memory you are currently executing from? You should try to avoid doing that.
2017-02-06 11:57 PM
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.
2017-02-07 01:29 AM
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
2017-02-07 09:15 AM
I guess the real question would be which STM32F3xx part specifically are you using, and how much FLASH it is supposed to come with.
2017-02-07 11:44 PM
Hello Clive,
its a STM32F302C8T6
so it should have 64kb Flash (0x08000000 to 0x0800FFFF) and a page size of 2kb (0x800)