我正在尝试跳回到重置 vector 并从 main 重新运行我的程序。这是我的代码,但它不起作用。这有什么问题吗?
typedef void (*reset_vector_jump)(void);
((reset_vector_jump)RESET_VECTOR_ADDRESS)();
最佳答案
所有这些评论都是相关的,但是如果您确实需要从有时需要的任何地方跳转到重置处理程序,特别是当您进行引导加载程序和重新编程时,这就是您的做法,您已经非常接近了。
在我的例子中,目标 Micro 是 Kinetis ARM cortex4,我的重置 vector 被硬编码在位置 0x00000004。见下文:
/* Interrupt vector table */
__attribute__ ((section (".vectortable"))) const tVectorTable __vect_table = {
/* ISR name No. Address Pri Name Description */
&__SP_INIT, /* 0x00 0x00000000 - ivINT_Initial_Stack_Pointer used by PE */
(tIsrFunc)&__thumb_startup, /* 0x01 0x00000004 - ivINT_Initial_Program_Counter used by PE */
};
因此位置 0x00000004 包含重置处理程序的地址,即 &__thumb_startup
。所以这就是我所做的:
typedef void (*reset_vector_jump)(void); //exactly as you've done
#define RESET_VECTOR_ADDRESS ((uint32_t *) 0x00000004) // a pointer to uint32_t
((reset_vector_jump)*RESET_VECTOR_ADDRESS)();//CALL IT
这对我有用。所以基本上你错过了一个额外的取消引用级别。 希望这可以帮助。
关于c - 跳转到重置 vector ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37857108/