Skip to main content
Fry
Associate
November 26, 2019
Question

Hello! Does anybody know why the function HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError) doesn't work properly with STM32F407, but the function works perfect with STM32F303?

  • November 26, 2019
  • 2 replies
  • 1534 views

Wnen I work with STM32F407 and call this function my programm goes to infinite loop cause of unexpected interrupt. But there is no problem with STM32F303.

Is there any features STM32F4 I don't know about?

This topic has been closed for replies.

2 replies

Bob S
Super User
November 26, 2019

need more information. Lets start with the usual suspects:

  • What is your memory map for both CPUs (i.e. where is your executable code located and how much FLASH does your code occupy)
  • What area of flash are you trying to erase
  • WHICH unexpected interrupt? You may well need to provide separate code for each of the fault routines (HardFault, BusFault, etc.) to see which one is triggering. Search this forum for @Community member​ (back as clive two point oh) HardFault handler code that reads the fault registers so you can see why the CPU ended up there.
  • Code, please. Otherwise you may as well ask "why isn't that thing over there orange?"

Fry
FryAuthor
Associate
November 28, 2019

Thank you for reply!

I want to learn how to work with FLASH memory, because i'll need to storage some data in my next project and i jast call that standart library function to earse, for example, last page (sector) .

The code i use is very simple:

void main (void)

{

1. uint32_t page_error = 0;

2. HAL_FLASH_Unlock();

3. EraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;

4. EraseInit.VoltageRange = FLASH_VOLTAGE_RANGE_3;

5. EraseInit.Sector = FLASH_SECTOR_11;

6. EraseInit.Banks = FLASH_BANK_1;

7. EraseInit.NbSectors = 1;

8. HAL_FLASHEx_Erase(&EraseInit,&page_error);

9. HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,0x080E0000,0x0AB6);

10.   HAL_FLASH_Lock();

11. while(1);

}

The program never reaches line 9 it goes to the point as shown below.

Fry
FryAuthor
Associate
November 27, 2019

Thank you for reply!

I want to learn how to work with FLASH memory, because i'll need to storage some data in my next project and i jast call that standart library function to earse, for example, last page (sector) .

The code i use is very simple:

void main (void)

{

1. uint32_t page_error = 0;

2. HAL_FLASH_Unlock();

3. EraseInit.TypeErase = FLASH_TYPEERASE_SECTORS;

4. EraseInit.VoltageRange = FLASH_VOLTAGE_RANGE_3;

5. EraseInit.Sector = FLASH_SECTOR_11;

6. EraseInit.Banks = FLASH_BANK_1;

7. EraseInit.NbSectors = 1;

8. HAL_FLASHEx_Erase(&EraseInit,&page_error);

9. HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD,0x080E0000,0x0AB6);

10.   HAL_FLASH_Lock();

11. while(1);

}

The program never reaches line 9 it goes to the point as shown below.