cancel
Showing results for 
Search instead for 
Did you mean: 

stm32h745zit6 flash wite and read.

Aravind1
Associate II

Hello experts,

I am trying to do basic write and read of internal flash. For that I have taken fixed pattern of data to write.

I am using the driver functions to do this job but when I observe the data in the memory browser the same pattern which iam trying to write is not reflecting. I am attaching my code below please let me know if missing anything.  

 

int main(void)

{

/* USER CODE BEGIN 1 */

 

/* USER CODE END 1 */

/* USER CODE BEGIN Boot_Mode_Sequence_0 */

int32_t timeout;

/* USER CODE END Boot_Mode_Sequence_0 */

 

/* USER CODE BEGIN Boot_Mode_Sequence_1 */

/* Wait until CPU2 boots and enters in stop mode or timeout*/

timeout = 0xFFFF;

// while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) != RESET) && (timeout-- > 0));

// if ( timeout < 0 )

// {

// Error_Handler();

// }

/* USER CODE END Boot_Mode_Sequence_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 Boot_Mode_Sequence_2 */

/* When system initialization is finished, Cortex-M7 will release Cortex-M4 by means of

HSEM notification */

/*HW semaphore Clock enable*/

__HAL_RCC_HSEM_CLK_ENABLE();

/*Take HSEM */

HAL_HSEM_FastTake(HSEM_ID_0);

/*Release HSEM in order to notify the CPU2(CM4)*/

HAL_HSEM_Release(HSEM_ID_0,0);

/* wait until CPU2 wakes up from stop mode */

timeout = 0xFFFF;

//while((__HAL_RCC_GET_FLAG(RCC_FLAG_D2CKRDY) == RESET) && (timeout-- > 0));

//if ( timeout < 0 )

//{

//Error_Handler();

//}

/* USER CODE END Boot_Mode_Sequence_2 */

 

/* USER CODE BEGIN SysInit */

 

/* USER CODE END SysInit */

 

/* Initialize all configured peripherals */

/* USER CODE BEGIN 2 */

 

HAL_FLASH_Unlock();

 

 

EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;

EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_1;

//EraseInitStruct.Banks = FLASH_BANK_2;

EraseInitStruct.Sector = 1;

EraseInitStruct.NbSectors = 3;

 

HAL_FLASHEx_Erase(&EraseInitStruct, &SECTORError);

adress = start;

HAL_Delay(10);

 

 

HAL_FLASH_Program(FLASH_TYPEPROGRAM_FLASHWORD, 0x08040000, 0x1234);

HAL_Delay(10);

Readdata = *( uint32_t *)start;

HAL_Delay(10);

/* USER CODE END 2 */

 

/* Infinite loop */

/* USER CODE BEGIN WHILE */

while (1)

{

/* USER CODE END WHILE */

 

/* USER CODE BEGIN 3 */

}

/* USER CODE END 3 */

}

 

 

 

 

1 REPLY 1

Please use this button to properly post source code:

AndrewNeil_0-1715766592190.png