Thread 中讨论的其他器件:C2000WARE
工具与软件:
大家好、团队成员:
我键入以跳转我的应用程序以及重置栈指针、但在汇编级别出现一些错误或我不理解的内容、因此对解决此问题有很大帮助。我将共享代码并尊重错误、如下所示。 
以上是代码剪切。
作为错误:-
说明资源路径位置类型
#18 Expected a ")" main.c /SC421_New_DSP Power_Convt_ line 292 C/C++问题。
此致、
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.
工具与软件:
大家好、团队成员:
我键入以跳转我的应用程序以及重置栈指针、但在汇编级别出现一些错误或我不理解的内容、因此对解决此问题有很大帮助。我将共享代码并尊重错误、如下所示。 
以上是代码剪切。
作为错误:-
说明资源路径位置类型
#18 Expected a ")" main.c /SC421_New_DSP Power_Convt_ line 292 C/C++问题。
此致、
void JumpToApplication(void)
{
//#if 0
// Define a function pointer to the application start address
void (*appStart)(void);
// Get the reset vector address (address of the application's reset handler)
appStart = (void (*)(void))(*((volatile uint32_t *)(APPLICATION_FLASH_START_ADDRESS + 0x4)));
// Disable interrupts
DINT;
// Set the stack pointer to the application's stack pointer
uint32_t appStackPointer = *(volatile uint32_t *)APPLICATION_FLASH_START_ADDRESS; // Get the stack pointer from the application's start address
__asm(" MOV DP, %0" : : "r" (appStackPointer)); // Set the stack pointer
// Jump to the application
appStart(); // Call the application
//#endif
/* // Disable interrupts
DINT; // Disable global interrupts
// Set the Stack Pointer (SP)
asm(" MOV DP, %0" : : "r" (STACK_START_ADDR)); // Set Data Pointer to stack address
asm(" MOV SP, %0" : : "r" (STACK_START_ADDR)); // Set Stack Pointer to stack address
// Set the Program Counter (PC) to the application start address
asm(" MOV DP, %0" : : "r" (APPLICATION_FLASH_START_ADDRESS)); // Set Data Pointer to application address
asm(" MOV PC, %0" : : "r" (APPLICATION_FLASH_START_ADDRESS)); // Set Program Counter to application address
// Set the Program Counter (PC) to the application start address
AppEntry appEntry = (AppEntry)(APPLICATION_FLASH_START_ADDRESS); // Cast the application start address to a function pointer
appEntry(); // Jump to the application
*/
/* // Define the new stack pointer location
// This should be a valid RAM address where the stack will start
volatile Uint32 *newStackPointer = (volatile Uint32 *)0x2000; // Change this address as needed
// Set the stack pointer to the new location
// In C, you can't directly assign to SP, so you need to use assembly
asm(" MOV A, newStackPointer"); // Load the address into A register
asm(" MOV SP, A"); // Move the value in A to the stack pointer
*/
/*
// Get the application's stack pointer value from the start of the image
uint32_t app_sp = *((uint32_t *)APP_START_ADDRESS);
// Get the application's entry point (Reset Handler)
AppEntryPoint app_entry = (AppEntryPoint)(*((uint32_t *)(APP_START_ADDRESS + 4)));
__asm(" MOV SP, @_stack_top");
// Reset the stack pointer (SP)
(__asm__ volatile ("MOV SP, %0" : : "r" (app_sp) : ));
// Jump to the application entry point
app_entry();
*/
void main(void)
{
//ReceiveCANData();
JumpToApplication();
}
}
嗨、Delaney、这里是共享函数、它从 main 调用级
_asm (" MOV DP,%0":"r"(appStackPointer));//设置堆栈指针
上面的行将在"linenum=15"中发现错误
错误: 描述资源路径位置类型
#18 Expected a ")" main.c /cps_SW_Gen5_New_DSP line 294 C/C++问题
此致
Ujwal AP.
尊敬的 Ujwal:
很抱歉我的答复被推迟。
asm 语句未在 C 或 C++标准中指定。 该特定变体来自 GCC。 我们基于 clang 的编译器(tiarmclang 和 c29clang)对其提供支持。 [报价]换句话说、C28x 编译器不支持您尝试使用的语句。 虽然 C28x 确实支持_asm 语句、但它们实际上应仅用于 EINT、NOP、ESTOP0等简单指令 MOV 指令要求 CPU 控制寄存器的已知状态才能工作;GCC 编译器知道如何定义这些状态、但 C28x 编译器不能。
我假设此代码用于自定义引导加载程序吗? 您是否在 引导加载程序的链接器 cmd 文件中为引导加载程序定义了单独的栈? 如果是、无需重置应用中的堆栈指针。 您需要做的就是跳转到应用程序代码、这通常是通过长分支指令完成的。
此致、
Delaney
大家好、团队
新年快乐!!!!
希望大家都做得很好、
对此、我还有一个问题、如下所示、
如果我们有代码、它存储在 ABCD 闪存扇区中、还有一个像 LED 闪烁这样的小代码将存储在"H"闪存扇区中、因此我想使用"asm (" LB 0x0A0000");"指令进行跳转、从而使两个代码都实现完美的切换或跳转
注意: 在上述两个代码仅由 TI 调试器推送。
现在、与 LED Blink Hex 文件相同的代码我想使用 CAN 协议以及 FlashAPI 函数存储、它成功地存储在闪存扇区"H"中、没有任何错误、但现在我想使用"asm (" LB 0x0A0000")跳转;"指令它不会跳转或直接跳转到函数以下。
_interrupt void Interrupt_illegalOperationHandler (void)
{
//
//有什么问题。 CPU 试图执行非法的
//指令、生成非法指令陷阱(ITRAP)。
//
ESTOP0;
for (;;)
{
;
}
}
我需要理解的是、如果我们使用 TI 调试器推送代码、那么两个代码会正确跳转且没有任何错误、但如果我们闪存相同的与"H"扇区相关的十六进制文件(LED 闪烁代码十六进制文件)、因此它存储得很好、但无法对其进行编码而不会跳转或切换、因此请关注此事项。
等待您的良好响应!!!!
此致
UJWAL AP
尊敬的 Ujwal:
所以、你能够使用 asm (" LB 0xA0000")正确分支至0xA0000;当你通过 JTAG/调试器刷写应用时、但不是当你通过闪存 API 编辑它时? 我的理解是否正确? 闪存 API 加载的内容和通过 JTAG/调试器加载的内容应该没有差异。 我建议对闪存扇区 H 进行一个内存转储、并在通过 JTAG/调试器进行编程以及通过闪存 API 进行编程时比较其内容。 如果您发现差异、则编程逻辑可能出错。
此致、
Skyler
尊敬的 Ujwal:
您可以尝试使用长间接分支指令。 因此、您需要将0xA0000存储在 XAR7寄存器中、然后使用 asm (" LB * XAR7")分支到该寄存器;
此指令在 TMS320C28x CPU 和指令集指南中有详细介绍、也可用于其他闪存内核。 您可以参考 F280015x DCAN 闪存内核工程(C2000ware/driverlib/f280015x/examples/flash/ccs/f280015x_flash_kernel_ex5_can_flash_kernel.projectspec)中的 flash_kernel_ex5_dcan_flash_kernel.c、了解其使用方法。
此致、
Skyler