1 解答
四月 18, 2022
02:12 AM
Hi GordonCat,
Write DFlash is different with PSPR DSPR, you need to erase sector, enter page mode, write page, please refer to below function in demo code Flash_Programming_1_KIT_TC397_TFT
void writeDataFlash()
{
uint32 page; /* Variable to cycle over all the pages */
/* --------------- ERASE PROCESS --------------- */
/* Get the current password of the Safety WatchDog module */
uint16 endInitSafetyPassword = IfxScuWdt_getSafetyWatchdogPassword();
/* Erase the sector */
IfxScuWdt_clearSafetyEndinit(endInitSafetyPassword); /* Disable EndInit protection */
IfxFlash_eraseMultipleSectors(DFLASH_STARTING_ADDRESS, DFLASH_NUM_SECTORS); /* Erase the given sector */
IfxScuWdt_setSafetyEndinit(endInitSafetyPassword); /* Enable EndInit protection */
/* Wait until the sector is erased */
IfxFlash_waitUnbusy(FLASH_MODULE, DATA_FLASH_0);
/* --------------- WRITE PROCESS --------------- */
for(page = 0; page < DFLASH_NUM_PAGE_TO_FLASH; page++) /* Loop over all the pages */
{
uint32 pageAddr = DFLASH_STARTING_ADDRESS + (page * DFLASH_PAGE_LENGTH); /* Get the address of the page */
/* Enter in page mode */
IfxFlash_enterPageMode(pageAddr);
/* Wait until page mode is entered */
IfxFlash_waitUnbusy(FLASH_MODULE, DATA_FLASH_0);
/* Load data to be written in the page */
IfxFlash_loadPage2X32(pageAddr, DATA_TO_WRITE, DATA_TO_WRITE); /* Load two words of 32 bits each */
/* Write the loaded page */
IfxScuWdt_clearSafetyEndinit(endInitSafetyPassword); /* Disable EndInit protection */
IfxFlash_writePage(pageAddr); /* Write the page */
IfxScuWdt_setSafetyEndinit(endInitSafetyPassword); /* Enable EndInit protection */
/* Wait until the data is written in the Data Flash memory */
IfxFlash_waitUnbusy(FLASH_MODULE, DATA_FLASH_0);
}
}
dw
2 回复数
四月 18, 2022
02:12 AM
Hi GordonCat,
Write DFlash is different with PSPR DSPR, you need to erase sector, enter page mode, write page, please refer to below function in demo code Flash_Programming_1_KIT_TC397_TFT
void writeDataFlash()
{
uint32 page; /* Variable to cycle over all the pages */
/* --------------- ERASE PROCESS --------------- */
/* Get the current password of the Safety WatchDog module */
uint16 endInitSafetyPassword = IfxScuWdt_getSafetyWatchdogPassword();
/* Erase the sector */
IfxScuWdt_clearSafetyEndinit(endInitSafetyPassword); /* Disable EndInit protection */
IfxFlash_eraseMultipleSectors(DFLASH_STARTING_ADDRESS, DFLASH_NUM_SECTORS); /* Erase the given sector */
IfxScuWdt_setSafetyEndinit(endInitSafetyPassword); /* Enable EndInit protection */
/* Wait until the sector is erased */
IfxFlash_waitUnbusy(FLASH_MODULE, DATA_FLASH_0);
/* --------------- WRITE PROCESS --------------- */
for(page = 0; page < DFLASH_NUM_PAGE_TO_FLASH; page++) /* Loop over all the pages */
{
uint32 pageAddr = DFLASH_STARTING_ADDRESS + (page * DFLASH_PAGE_LENGTH); /* Get the address of the page */
/* Enter in page mode */
IfxFlash_enterPageMode(pageAddr);
/* Wait until page mode is entered */
IfxFlash_waitUnbusy(FLASH_MODULE, DATA_FLASH_0);
/* Load data to be written in the page */
IfxFlash_loadPage2X32(pageAddr, DATA_TO_WRITE, DATA_TO_WRITE); /* Load two words of 32 bits each */
/* Write the loaded page */
IfxScuWdt_clearSafetyEndinit(endInitSafetyPassword); /* Disable EndInit protection */
IfxFlash_writePage(pageAddr); /* Write the page */
IfxScuWdt_setSafetyEndinit(endInitSafetyPassword); /* Enable EndInit protection */
/* Wait until the data is written in the Data Flash memory */
IfxFlash_waitUnbusy(FLASH_MODULE, DATA_FLASH_0);
}
}
dw