uint32_t Fapi_BlockProgram( uint32_t Bank, uint32_t Flash_Address, uint32_t Data_Address, uint32_t SizeInBytes)
{
register uint32_t src = Data_Address;
register uint32_t dst = Flash_Address;
uint32_t bytes;
if (SizeInBytes < 16)
bytes = SizeInBytes;
else
bytes = 16;
if ((Fapi_initializeFlashBanks((uint32_t)SYS_CLK_FREQ)) == Fapi_Status_Success)
{
(void)Fapi_setActiveFlashBank(Fapi_FlashBank7);
if(Bank >= 7)
Fapi_enableEepromBankSectors(0xffffffff, 0xffffffff);
else
(void)Fapi_enableMainBankSectors(0xFFFF); /* used for API 2.01*/
}else
{
return (1);
}
while( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady );
while( FAPI_GET_FSM_STATUS != Fapi_Status_Success );
while( SizeInBytes > 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;
dst += bytes;
SizeInBytes -= bytes;
if ( SizeInBytes < 16){
bytes = SizeInBytes;
}
}
return (0);
}
这是写扇区的函数,有的时候可以写进去,有的时候卡在第二个while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);这里,一直循环
user5822303:
有的时候能写进去,有的时候会卡在while(FAPI_GET_FSM_STATUS != Fapi_Status_Success);这里,一直循环
Susan Yang:
请问您现在使用的是哪款芯片?