cancel
Showing results for 
Search instead for 
Did you mean: 

B-L475E-IOT01A Flash Erase & Write

GKIM.4
Associate II

I want to work on flash with B-L475E-IOT01A1.

After flash erase operation, flash write operation is performed, and memory is being checked through debugging.

On other boards, flash erase operation changed the memory in that location to the "?" mark, but the memory of this board does not change.

Doesn't it matter?

And if I do flash write, the data is not saved.

What's the problem?

This code is currently in use.

#define FLASH_START_ADDR  ((uint32_t)0x0807F800)

#define ERASE_PAGE ((uint32_t)0x0FF)

int ii, jj, kk, ll, mm, nn;

int Ns = 4;

uint16_t Buffer = 1861;

uint32_t flash_write_address = FLASH_START_ADDR;

uint64_t flash_write_buffer;

int main(void)

{

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the Systick. */

HAL_Init();

/* USER CODE BEGIN Init */

/* USER CODE END Init */

/* Configure the system clock */

SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */

MX_GPIO_Init();

MX_DFSDM1_Init();

MX_I2C2_Init();

MX_QUADSPI_Init();

MX_SPI3_Init();

MX_USART1_UART_Init();

MX_USART3_UART_Init();

MX_USB_OTG_FS_PCD_Init();

/* USER CODE BEGIN 2 */

/* USER CODE END 2 */

/* Infinite loop */

/* USER CODE BEGIN WHILE */

HAL_FLASH_Unlock();

FLASH_PageErase(ERASE_PAGE, FLASH_BANK_1);

HAL_FLASH_Lock();

while (1)

{

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */

HAL_FLASH_Unlock();

flash_write_buffer = (uint64_t)Buffer;

HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, flash_write_address, flash_write_buffer);

HAL_FLASH_Lock();

HAL_Delay(1000);

}

/* USER CODE END 3 */

}

0 REPLIES 0