We used the IAP Flash concept to store the data in our customised board. In some boards it works properly. But in some of the board, it not executed while entering the function of flash property controller get hanged. How can i resolve this issue. Here by I updated the code we generated
#include "fsl_iap.h"
#include "fsl_iap_ffr.h"
#include "init.h"
#define PAGE_INDEX_FROM_END 1U
flash_config_t flashInstance;
static uint32_t status;
uint32_t destAdrss; /* Address of the target location */
uint32_t failedAddress, failedData;
uint32_t pflashBlockBase = 0;
uint32_t pflashTotalSize = 0;
uint32_t pflashSectorSize = 0;
uint32_t PflashPageSize = 0;
void IAP_Flashwrite(void);
void IAP_Flashread(void);
void IAP_Address_cap(void);
int main()
{
IAP_Address_cap();
void IAP_Flashwrite(void);
IAP_Flashread();
while(1)
{
}
}
void IAP_Address_cap()
{
FLASH_Init(&flashInstance);
/* Get flash properties kFLASH_ApiEraseKey */
FLASH_GetProperty(&flashInstance, kFLASH_PropertyPflashBlockBaseAddr, &pflashBlockBase);
FLASH_GetProperty(&flashInstance, kFLASH_PropertyPflashSectorSize, &pflashSectorSize);
FLASH_GetProperty(&flashInstance, kFLASH_PropertyPflashTotalSize, &pflashTotalSize);
FLASH_GetProperty(&flashInstance, kFLASH_PropertyPflashPageSize, &PflashPageSize);
destAdrss = pflashBlockBase + (pflashTotalSize - (PAGE_INDEX_FROM_END * PflashPageSize));
}
void IAP_Flashwrite(void)
{
static uint8_t status;
status = FLASH_Erase(&flashInstance, destAdrss, PflashPageSize, kFLASH_ApiEraseKey);
status = FLASH_VerifyErase(&flashInstance, destAdrss, PflashPageSize);
/* Start programming specified flash region */
status = FLASH_Program(&flashInstance, destAdrss, (uint8_t *)IAP_data_buffer, sizeof(IAP_data_buffer));
// /* Verify if the given flash region is successfully programmed with given data */
// status = FLASH_VerifyProgram(&flashInstance, destAdrss, sizeof(Write_byte),
// (const uint8_t *)Write_byte, &failedAddress, &failedData);
}
void IAP_Flashread(void)
{
destAdrss = pflashBlockBase + (pflashTotalSize - (PAGE_INDEX_FROM_END * PflashPageSize));
/* Verify programming by reading back from flash directly */
for (uint32_t i = 0; i < 64; i++)
{
IAP_data_buffer[i] = *(volatile uint32_t *)(destAdrss + i * 4); //IAP_data_buffer
}
}