TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS570LS0914:在使用Fapi_BlockErase擦除flash的时候卡死?

目前在执行Fapi_BlockProgram( 0, addr, (uint32_t)data, 4); 语句卡住,测试地址为0x000FFC00。

发现是卡在while( FAPI_GET_FSM_STATUS!= Fapi_Status_Success );但是之前我们在TMS570LS1224开发板上测试是OK的,用同样的程序在TMS570LS0914上测试就会卡死,不知道这两者的芯片有什么区别?

 

 

 

Susan Yang:

请问您的flash API的版本是多少?不同的版本,用法略有差异。

是否enable了您准备擦写的sectors:

Fapi_enableMainBankSectors(0xFFFF);

另外当代码也在同一个bank运行时,您无法erase/programflash bank 。这时您需要在RAM内运行 Flash API

user5792549:

回复 Susan Yang:

我这个代码是从网上找的,我也不知道这个版本是多少,你能告诉我哪里能看到版本吗?

目前我擦除的是0扇区,在擦除前使用了Fapi_enableMainBankSectors(0xFFFF);或Fapi_enableMainBankSectors(0);还是一样会卡死

另外,我把Flash API相关函数都是放到RAM中运行的(这个是保证的)

user5792549:

回复 Susan Yang:

并且我仿真发现while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);这个寄存器一直返回0x810,目前所使用的的代码原型如下:

uint32_t Fapi_BlockErase( uint32_t Bank, uint32_t Flash_Start_Address, uint32_t Size_In_Bytes)
{uint32_t status;uint32_t Freq_In_MHz;uint8_ti, j, bk, ucStartBank, ucStartSector, ucEndBank;uint32_t *eraseStartAddr0;uint32_t *eraseStartAddr;intremaining;uint32_t Flash_End_Address;ucStartBank = 0, i=0, ucStartSector = 0;ucEndBank = 0;eraseStartAddr0 = (uint32_t *)Flash_Start_Address;eraseStartAddr = (uint32_t *)Flash_Start_Address;Flash_End_Address = Flash_Start_Address + Size_In_Bytes;Freq_In_MHz = SYS_CLK_FREQ;for (i = 0; i < NUMBEROFSECTORS-1; i++){if (Flash_Start_Address == (uint32_t)(flash_sector[i].start)){ucStartBank= flash_sector[i].bankNumber;ucStartSector= flash_sector[i].sectorNumber;eraseStartAddr0 = flash_sector[i].start;eraseStartAddr= flash_sector[i].start;break;}}for (i = ucStartSector; i < NUMBEROFSECTORS-1; i++){if (Flash_End_Address <= ((uint32_t)(flash_sector[i].start) + flash_sector[i].length)){ucEndBank= flash_sector[i].bankNumber;break;}}//F021_CPU0_REGISTER_ADDRESS is defined as 0xfff87000 in FMC.h//Fapi_initializeAPI((Fapi_FmcRegistersType *)F021_CPU0_REGISTER_ADDRESS, Freq_In_MHz); /*used for API Rev1.5*/Fapi_initializeFlashBanks(Freq_In_MHz); /* used for API Rev2.01 */for (bk = ucStartBank; bk < ucEndBank+1; bk++){Fapi_setActiveFlashBank((Fapi_FlashBankType)bk);if (bk == 0){j = ucStartSector;//0remaining = Size_In_Bytes;//4}else{j = 0;}Fapi_enableMainBankSectors(0xFFFF);/* used for API 2.01*/while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );do{Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, eraseStartAddr);//Fapi_issueAsyncCommandWithAddress(Fapi_ProgramData, eraseStartAddr);while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);
//while(FAPI_GET_FSM_STATUS != Fapi_Status_Success){status = FAPI_GET_FSM_STATUS;}remaining -= flash_sector[j++].length;eraseStartAddr = flash_sector[j].start;}while((remaining > 0) && ( j < flash_bank[bk].numOfSectors));}status =Flash_Erase_Check((uint32_t)eraseStartAddr0, Size_In_Bytes);return (status);
}

uint32_t Fapi_BlockProgram( uint32_t Bank, uint32_t Flash_Start_Address, uint32_t Data_Start_Address, uint32_t Size_In_Bytes)
{register uint32_t src = Data_Start_Address;register uint32_t dst = Flash_Start_Address;register uint32_t bytes_remain = Size_In_Bytes;uint8_ti, ucBank;uint32_t status;uint32_t bytes;uint32_t Freq_In_MHz;Freq_In_MHz = SYS_CLK_FREQ;if (Size_In_Bytes < 16)bytes = Size_In_Bytes;elsebytes = 16;for (i = 0; i < NUMBEROFSECTORS-1; i++){if (Flash_Start_Address < (uint32_t)(flash_sector[i+1].start)){ucBank= flash_sector[i].bankNumber;break;}}if(( Flash_Start_Address == APP_START_ADDRESS ) || ( ucBank == 1 )){Fapi_initializeFlashBanks(Freq_In_MHz); /* used for API Rev2.01 */Fapi_setActiveFlashBank((Fapi_FlashBankType)ucBank);Fapi_enableMainBankSectors(0xFFFF);/* used for API 2.01*/while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );while( FAPI_GET_FSM_STATUS!= Fapi_Status_Success );}while( bytes_remain > 0){Fapi_issueProgrammingCommand((uint32_t *)dst,(uint8_t *)src,(uint32_t) bytes,0,0,Fapi_AutoEccGeneration);while( FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy );while(FAPI_GET_FSM_STATUS!= Fapi_Status_Success);src += bytes;//Size_In_Bytes;dst += bytes; //Size_In_Bytes;bytes_remain -= bytes; //Size_In_Bytes;if ( bytes_remain < 16){bytes = bytes_remain;}}#ifdef DEBUG_MSG_L3UART_putString(UART, "\r Programmed the flash: ");UART_send32BitData(UART, Size_In_Bytes);UART_putString(UART, "Bytes. \r ");
#endifstatus =Flash_Program_Check(Flash_Start_Address, Data_Start_Address, Size_In_Bytes);return (status);
}

赞(0)
未经允许不得转载:TI中文支持网 » TMS570LS0914:在使用Fapi_BlockErase擦除flash的时候卡死?
分享到: 更多 (0)