28377d,Fapi_StatusType Fapi_issueAsyncCommandWithAddress()使用问题

luwfee luwfee 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

请教各位,F021中的函数
extern Fapi_StatusType Fapi_issueAsyncCommandWithAddress(
Fapi_FlashStateCommandsType oCommand,
uint32 *pu32StartAddress
);
在使用时有何要注意的,为什么,我一执行这个函数,擦除一个sector,就会导致芯片复位呢~~~
问题说明:将Flash用来实现设备参数掉电保存,待保存参数按顺序写入目标Flash sector中,本次写入不覆盖上次写入的区域,当本sector不足时,将sector擦除,从头开始写。现在的问题是,只要一执行erase操作,芯片就复位,programme写入操作却没有问题,请知情者协助~~

FLASH配置代码如下:
void InitFlash(void)
{
EALLOW;
//
// Set VREADST to the proper value for the flash banks to power up
// properly. This sets the bank power up delay.
//
Flash0CtrlRegs.FBAC.bit.VREADST = 0x14;
//
// At reset bank and pump are in sleep. A Flash access will power up the
// bank and pump automatically.
//
// After a Flash access, bank and pump go to low power mode (configurable
// in FBFALLBACK/FPAC1 registers) if there is no further access to flash.
//
// Power up Flash bank and pump. This also sets the fall back mode of
// flash and pump as active.
//
Flash0CtrlRegs.FPAC1.bit.PMPPWR = 0x1;
Flash0CtrlRegs.FBFALLBACK.bit.BNKPWR0 = 0x3;
//
// Disable Cache and prefetch mechanism before changing wait states
//
Flash0CtrlRegs.FRD_INTF_CTRL.bit.DATA_CACHE_EN = 0;
Flash0CtrlRegs.FRD_INTF_CTRL.bit.PREFETCH_EN = 0;
//
// Set waitstates according to frequency
//
// *CAUTION*
// Minimum waitstates required for the flash operating at a given CPU rate
// must be characterized by TI. Refer to the datasheet for the latest
// information.
//
#if CPU_FRQ_200MHZ
Flash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x3;
#endif
#if CPU_FRQ_150MHZ
Flash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x2;
#endif
#if CPU_FRQ_120MHZ
Flash0CtrlRegs.FRDCNTL.bit.RWAIT = 0x2;
#endif
//
// Enable Cache and prefetch mechanism to improve performance of code
// executed from Flash.
//
Flash0CtrlRegs.FRD_INTF_CTRL.bit.DATA_CACHE_EN = 1;
Flash0CtrlRegs.FRD_INTF_CTRL.bit.PREFETCH_EN = 1;
//
// At reset, ECC is enabled. If it is disabled by application software and
// if application again wants to enable ECC.
//
Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0xA;
EDIS;
//
// Force a pipeline flush to ensure that the write to the last register
// configured occurs before returning.
//
__asm(" RPT #7 || NOP");
}

//
// SeizeFlashPump - Wait until the flash pump is available. Then take control
// of it using the flash pump Semaphore.
//
void SeizeFlashPump(void)
{
EALLOW;
#ifdef CPU1
while (FlashPumpSemaphoreRegs.PUMPREQUEST.bit.PUMP_OWNERSHIP != 0x2)
{
FlashPumpSemaphoreRegs.PUMPREQUEST.all = IPC_PUMP_KEY | 0x2;
}
#elif defined(CPU2)
while (FlashPumpSemaphoreRegs.PUMPREQUEST.bit.PUMP_OWNERSHIP != 0x1)
{
FlashPumpSemaphoreRegs.PUMPREQUEST.all = IPC_PUMP_KEY | 0x1;
}
#endif
EDIS;
}

//
// Init_Flash_Sectors - Initialize flash API and active flash bank sectors
//
void Init_Flash_Sectors(void)
{
EALLOW;
Flash0EccRegs.ERR_THRESHOLD.bit.ERR_THRESHOLD = 0x1;
Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0x0;
Fapi_StatusType oReturnCheck;
//
// This function is required to initialize the Flash API based on System
// frequency before any other Flash API operation can be performed
//
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 200);
if(oReturnCheck != Fapi_Status_Success)
{
Example_Error(oReturnCheck);
}
//
// Fapi_setActiveFlashBank function sets the Flash bank and FMC for further
// Flash operations to be performed on the bank
//
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0);
if(oReturnCheck != Fapi_Status_Success)
{
Example_Error(oReturnCheck);
}
Flash0EccRegs.ECC_ENABLE.bit.ENABLE = 0xA;
EDIS;
}



erase和programme操作如下:
#pragma CODE_SECTION(StoreData2Flash, ramFuncSection);
int StoreData2Flash(Uint16 *start, Uint32 size, Uint16 sector)
{
//1. declare the variables used for programming flash
Fapi_StatusType oReturnCheck = 0;// Status structure
Fapi_FlashStatusWordType oFlashStatusWord;
volatile Fapi_FlashStatusType oFlashStatus;
uint32 u32Index = 0;
uint16 i = 0;
Uint32 lTemp;
Uint32 lSectorAddr;
uint32 *Buffer32 = (uint32 *)start;
EALLOW;
DINT; // disable global interrupt
//2. check if the sector storing data record is full. if yes then erase the sector
switch(sector)
{
case SECTORK: lSectorAddr = Bzero_SectorK_start; break;
case SECTORL: lSectorAddr = Bzero_SectorL_start; break;
case SECTORM: lSectorAddr = Bzero_SectorM_start; break;
case SECTORN: lSectorAddr = Bzero_SectorN_start; break;
default:
EINT;
return 1;
}
lTemp = lSectorAddr;
// search for the most recent data ration record in flash
while(*(unsigned long*)lTemp != 0xFFFFFFFF) // the value at lTemp is not 0xFFFFFFFF which means the location at lTemp is not programmed with some value
{
lTemp += size;
}
if(lSectorAddr + 0x2000 - lTemp < size) // if the flash is full, erase the sector
{
// Erase Sector
//
oReturnCheck = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,(uint32 *)lSectorAddr);
// Wait until FSM is done with erase sector operation
while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady){}
// Verify that SectorL is erased. The Erase step itself does a
// verify as it goes. This verify is a 2nd verification that can be done.
oReturnCheck = Fapi_doBlankCheck((uint32 *)lSectorAddr,Bzero_16KSector_u32length,&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
EINT;
return 1;
}
lTemp = lSectorAddr;
}
//3. program the data record to flash
for(i=0, u32Index = lTemp;
(u32Index < (lTemp + size)) &&
(oReturnCheck == Fapi_Status_Success); i+= 8, u32Index+= 8)
{
oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,start+i,
8,
0,
0,
Fapi_AutoEccGeneration);
while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
EINT;
return 1;
}
//
// Read FMSTAT register contents to know the status of FSM after
// program command for any debug
//
oFlashStatus = Fapi_getFsmStatus();
//
// Verify the values programmed. The Program step itself does a verify
// as it goes. This verify is a 2nd verification that can be done.
//
oReturnCheck = Fapi_doVerify((uint32 *)u32Index,
4, Buffer32+(i/2),
&oFlashStatusWord);
if(oReturnCheck != Fapi_Status_Success)
{
//
// Check Flash API documentation for possible errors
//
EINT;
return 1;
}
}
EINT;
return 0;
}
...全文

相关推荐

告别串口烧录器:手把手教你为TMS320F28377D DSP实现串口在线升级(Bootloader实战)

本文详细介绍了如何为TMS320F28377D DSP实现串口在线升级(Bootloader实战),通过双工程架构和安全通信协议,告别传统JTAG烧录模式。文章涵盖了硬件架构设计、串口通信协议优化、Flash操作安全实践及现场部署技巧,帮助开发者构建工业级远程升级方案,显著提升效率并降低故障率。

Cristalsil苏

给TMS320F28377D做个‘心脏搭桥’:手把手教你设计Bootloader,实现串口一键升级

本文详细介绍了为TMS320F28377D DSP芯片设计Bootloader的完整流程,实现串口一键在线升级功能。通过双工程布局、串口通信协议设计、Fapi库函数应用及鲁棒性设计,帮助工程师在工业现场实现高效固件更新,大幅提升设备维护效率。

学习汪汪

告别仿真器!手把手教你为TMS320F28377D实现串口Bootloader(附完整CMD配置)

本文详细介绍了为TMS320F28377D DSP芯片开发工业级串口Bootloader的完整方案,涵盖双工程内存布局、通信协议设计、Flash操作优化及断电保护等关键技术。通过实战案例和CMD配置示例,帮助开发者实现远程在线升级,提升工业设备维护效率。

许风倾秋

别再手动烧录了!手把手教你为TMS320F28377D DSP实现串口Bootloader(附完整CMD文件配置)

本文详细介绍了为TMS320F28377D DSP实现串口Bootloader的完整方案,包括内存分区策略、FAPI库的实战技巧以及如何规避多工程共存时的内存冲突。通过串口Bootloader,开发者可以告别低效的仿真器烧录方式,实现一键空中升级,大幅提升生产效率和维护便利性。

朕忠

DSP在线升级(2)--Bootloader的模块化设计与通信协议集成

本文详细探讨了DSP在线升级中Bootloader的模块化设计与通信协议集成。通过拆分成启动管理、通信接口、Flash操作和状态机等核心模块,实现高效稳定的远程更新功能。重点介绍了UART、CAN和以太网通信协议的集成技巧,以及Flash操作的安全陷阱和状态机设计的最佳实践,助力开发者构建可靠的DSP在线升级系统。

狸花实验室
评论 1
收藏 已收藏
分享
返回顶部
luwfee
其它技术问题 3,880 成员 9,044 内容