您好、团队成员:
我在调试器件时遇到了问题。
项目构建正确、处理器可能也进行了正确编程、但当我单击"play"按钮时、CPU 会堆栈在引导 ROM 中:


问题随机出现。 当我编辑代码时、即使只是删除或添加一行代码项目、也会正确编译、并且 CPU 可以正常运行、正如我预期的那样。
您知道什么可能触发此故障行为吗?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好、团队成员:
我在调试器件时遇到了问题。
项目构建正确、处理器可能也进行了正确编程、但当我单击"play"按钮时、CPU 会堆栈在引导 ROM 中:


问题随机出现。 当我编辑代码时、即使只是删除或添加一行代码项目、也会正确编译、并且 CPU 可以正常运行、正如我预期的那样。
您知道什么可能触发此故障行为吗?
您好、Mateusz:
Unknown 说:项目构建正确、处理器可能也编程正确、但当我点击"play"按钮时、CPU 会堆叠在引导 ROM 中
您能否尝试单步执行代码以查看问题发生在哪一行? 根据您的屏幕截图、看起来这可能是 ITRAP (指令陷阱、当运行无效指令时会发生)。 在执行此操作时、请确保查看反汇编以验证正在执行有效指令。
Unknown 说:当我编辑代码时、即使只是删除或添加一行代码项目时、CPU 也能正确编译、CPU 也能正常运行。 [/报价]您能详细说明一下您正在编辑什么内容吗? 是您要删除的某一行还是仅某些行? 请进行全面测试、以便我们缩小问题根源。
此致、
阿米尔·奥马尔
您好、Omer:
我找到了什么触发了 ITRAP、但我不知道为什么这个函数一次触发了非法操作 INT、但一次不会触发。
该函数是 Fapi_setActiveFlashBank (Fapi_Flash 1)、我在器件初始化过程结束时执行该函数:
void Device_init(void)
{
//
// Disable the watchdog
//
SysCtl_disableWatchdog();
#ifdef CMDTOOL
CMD_init();
#endif
#ifdef _FLASH
#ifndef CMDTOOL
//
// Copy time critical code and flash setup code to RAM. This includes the
// following functions: InitFlash();
//
// The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart symbols
// are created by the linker. Refer to the device .cmd file.
//
memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
#endif
//
// Call Flash Initialization to setup flash waitstates. This function must
// reside in RAM.
//
Flash_initModule(FLASH0CTRL_BASE, FLASH0ECC_BASE, DEVICE_FLASH_WAITSTATES);
#endif
//
// Set up PLL control and clock dividers
//
SysCtl_setClock(DEVICE_SETCLOCK_CFG);
//
// Make sure the LSPCLK divider is set to the default (divide by 4)
//
SysCtl_setLowSpeedClock(SYSCTL_LSPCLK_PRESCALE_1);
//
// These asserts will check that the #defines for the clock rates in
// device.h match the actual rates that have been configured. If they do
// not match, check that the calculations of DEVICE_SYSCLK_FREQ and
// DEVICE_LSPCLK_FREQ are accurate. Some examples will not perform as
// expected if these are not correct.
//
ASSERT(SysCtl_getClock(DEVICE_OSCSRC_FREQ) == DEVICE_SYSCLK_FREQ);
ASSERT(SysCtl_getLowSpeedClock(DEVICE_OSCSRC_FREQ) == DEVICE_LSPCLK_FREQ);
#ifndef _FLASH
//
// Call Device_cal function when run using debugger
// This function is called as part of the Boot code. The function is called
// in the Device_init function since during debug time resets, the boot code
// will not be executed and the gel script will reinitialize all the
// registers and the calibrated values will be lost.
// Sysctl_deviceCal is a wrapper function for Device_Cal
//
SysCtl_deviceCal();
#endif
//
// Turn on all peripherals
//
Device_enableAllPeripherals();
//
// Lock VREGCTL Register
// The register VREGCTL is not supported in this device. It is locked to
// prevent any writes to this register
//
ASysCtl_lockVREG();
//
// Configure GPIO20 and GPIO21 as digital pins
//
GPIO_setAnalogMode(20U, GPIO_ANALOG_DISABLED);
GPIO_setAnalogMode(21U, GPIO_ANALOG_DISABLED);
/*
* SET MCAN CLOCK PRESCALER
*/
SysCtl_setMCANClk(SYSCTL_MCANCLK_DIV_1);
//
// Jump to RAM and call the Flash API functions
//
CallFlashAPI();
}
#pragma CODE_SECTION(CallFlashAPI, ".TI.ramfunc");
void CallFlashAPI(void)
{
//
// This function is required to initialize the Flash API based on
// System frequency before any other Flash API operation can be performed
// Note that the FMC register base address and system frequency are passed as the parameters
//
// This function must also be called whenever System frequency or RWAIT is changed.
//
oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, CPUCLK_FREQUENCY);
if(oReturnCheck != Fapi_Status_Success)
{
Example_Error(oReturnCheck);
}
//
// Fapi_setActiveFlashBank function initializes Flash bank
// and FMC for erase and program operations.
//
#warning triggers post C init
oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank1);
if(oReturnCheck != Fapi_Status_Success)
{
Example_Error(oReturnCheck);
}
}

此处检测到非法操作。
在执行擦除和编程操作之前、我的整个代码可以正常工作、闪存 API 可以正常工作、而没有设置闪存存储体。
在本例中进行 FAPI 初始化就足够了、但我确信必须设置 bank1、因为我正在对 bank1扇区进行操作。 也许在这个 MCU 中、 没有必要设置适当的闪存存储体?
另一个问题未解决。 例如、当我编辑代码时、即使它是一行的重复、也可以为变量分配新值。
(*data[1]).module1.modulesID.all = 0x0;
(*data[1]).module2.modulesID.all = 0x0;
(*data[1]).module3.modulesID.all = 0x0;
(*data[1]).module4.modulesID.all = 0x0;
使用函数 Fapi_setActiveFlashBank(event1) Fapi_Flash 的项目工作正常。
我找到了什么触发了 ITRAP,但我不知道为什么这个函数一旦触发了非法操作 INT 而不是一次。 [/报价]您是否确保闪存 API 函数未从正在运行的闪存组中运行? 这在闪存 API 用户指南中进行了说明:
此外、请确保不会修改您调用函数的位置(也就是说、如果函数所在的位置为 RAM 未初始化或闪存未被擦除)。
[/quote]当我编辑代码时,例如,即使它重复了一行,为变量分配一个新值。 [/报价]请您重新写下该问题/陈述吗? 我不确定我是否理解这意味着什么、或者下面的代码中涉及的内容。 您是说您无法为变量分配值吗?
您是否确定闪存 API 函数未从正在运行的闪存组运行? 这是闪存 API 用户指南中描述的内容:
我确信 flashAPI 位于 RAM 中、因此我假定从 RAM 运行。
FlashAPIlib 位于闪存组0中、然后传输到 RAM。 我正在闪存存储体1上运行、这是我在调用函数 Fapi setActiveFlashBank (Fapi_Flash 1)时希望设置的存储体。

还要确保没有任何内容正在修改您调用函数的位置(例如,如果函数所在的位置是 RAM 未初始化或闪存未被擦除)。
RAM 和闪存在 CallFlashAPI ()之前初始化,我确信在调用闪存 API 之后启用了中断。
您能改写此问题/陈述吗? 我不确定我是否理解这意味着什么、或者下面的代码中涉及的内容。 您是否说无法为变量分配值?
我想说的是、对代码和输出文件进行的一些修改使 函数 Fapi_setActiveFlashBank(Fapi_Flash 52 1)的项目能够正常工作。 这一点我还不清楚、因为一旦项目正常运行、而在修改前未使用该功能。
现在、我每次使用闪存 API 时都添加了 EALLOW 和 EDIS 指令、这似乎可以解决问题。
我不知道为什么这对于代码功能是必要的、我会将这篇文章转发给闪存专家、以确认为什么这使您的程序正常工作。 由于他们目前因节假日不在办公室、敬请期待下周三左右的回复。
尊敬的 Vamis:
很抱歉这么晚才回答。 以下是请求提供的信息。
您能否附上您正在使用的设备的图像? [/报价]
此外,请从调试器内存窗口共享 TI-OTP 内存转储。
e2e.ti.com/.../TI_5F00_OTP_5F00_0x70000_5F00_0x703FF.txt
谢谢。此致、
M·斯塔西亚克
[/quote]
尊敬的 Vamsi:
您能否共享链接器命令文件和映射文件? 您可以从其中删除任何专有信息。
从您共享的快照中、我看到闪存 driverlib 被复制到 RAM 中。 我想确认是否将闪存 API 本身复制到 RAM 中。 谢谢你。
[/报价]在源文件中、我使用#pragma code_section 指令将 FlashAPI 函数添加到 ".TI.ramfunc"程序块。
例如:
#pragma CODE_SECTION(CallFlashAPI, ".TI.ramfunc"); void CallFlashAPI(void) { EALLOW; // // This function is required to initialize the Flash API based on // System frequency before any other Flash API operation can be performed // Note that the FMC register base address and system frequency are passed as the parameters // // This function must also be called whenever System frequency or RWAIT is changed. // oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, CPUCLK_FREQUENCY); if(oReturnCheck != Fapi_Status_Success) { Example_Error(oReturnCheck); } // // Fapi_setActiveFlashBank function initializes Flash bank // and FMC for erase and program operations. // oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank1); if(oReturnCheck != Fapi_Status_Success) { Example_Error(oReturnCheck); } EDIS; }该指令从我的定制闪存 API 源文件中分配我的所有函数。
在我的函数内的每个 flashAPI 驱动程序库函数都在 FLASH_BANK_0中分配。
这是项目中的.map 文件的一部分。
.TI.ramfunc * 0 00081000 000001c5 RUN ADDR = 00008000 00081000 00000049 driverlib.lib : flash.obj (.TI.ramfunc:Flash_initModule) 00081049 0000003c Fapi_UserDefinedFunctions.obj (.TI.ramfunc:writeVector) 00081085 00000031 Fapi_UserDefinedFunctions.obj (.TI.ramfunc:FlashAPIEraseSectorIDVector) 000810b6 0000002c driverlib.lib : flash.obj (.TI.ramfunc:Flash_setBankPowerMode) 000810e2 00000023 : flash.obj (.TI.ramfunc:Flash_setWaitstates) 00081105 0000001d : flash.obj (.TI.ramfunc:Flash_setPumpPowerMode) 00081122 00000019 Fapi_UserDefinedFunctions.obj (.TI.ramfunc:CallFlashAPI) 0008113b 00000018 driverlib.lib : flash.obj (.TI.ramfunc:Flash_disableCache) 00081153 00000018 : flash.obj (.TI.ramfunc:Flash_disablePrefetch) 0008116b 00000017 : flash.obj (.TI.ramfunc:Flash_enableCache) 00081182 00000017 : flash.obj (.TI.ramfunc:Flash_enablePrefetch) 00081199 00000016 : flash.obj (.TI.ramfunc:Flash_enableECC) 000811b7 00000006 Fapi_UserDefinedFunctions.obj (.TI.ramfunc:Example_Error) 000811bd 00000004 driverlib.lib : sysctl.obj (.TI.ramfunc) 000811c1 00000004 f28003x_usdelay.obj (.TI.ramfunc) ######################################################################################## ###################### The rest of the Fapi functions ######################################################################################## 0 0000f9b8 Fapi_GlobalInit 0 0008bffe Fapi_WriteReadBack 0 0008b9cf Fapi_calculateFletcherChecksum 0 0008c6ac Fapi_calculateOtpChecksum 0 0008c630 Fapi_checkFsmForReady 0 0008a86c Fapi_checkRegionForValueBy16bits 0 0008af85 Fapi_configureFMAC 0 0008b9fb Fapi_divideUnsignedLong 0 0008a7f0 Fapi_doBlankCheck 0 0008c5d6 Fapi_doVerifyBy16bits 0 0008be78 Fapi_flushPipeline 0 0008c99a Fapi_getFsmStatus 0 0008b7ec Fapi_initializeAPI 0 0008bca9 Fapi_isAddressEcc 0 0008b526 Fapi_isAddressValid 0 0008a770 Fapi_issueAsyncCommandWithAddress 0 0008b047 Fapi_issueFsmCommand 0 00087b56 Fapi_issueProgrammingCommand 0 0008a8e7 Fapi_loopRegionForValue 0 0008b784 Fapi_loopRegionForValueBy16bits 0 0008c81b Fapi_scaleCycleValues 0 0008b59b Fapi_setActiveFlashBank 0 0008b8b3 Fapi_setupBankSectorEnable 0 0008bf07 Fapi_setupSectorsForWrite 0 00008085 FlashAPIEraseSectorIDVector 0 00008000 Flash_initModule我不知道这是否会是个问题。 我没有在 FLASH_BANK_0上操作、而是在 没有闪存 API 函数的 Bank_1上操作。
此致、
马特乌斯