完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
已经按例程全改了,运行程序还是进入HardFault.
1、------------------------------------------------------------ PendSV_Handler CPSID I ; Prevent interruption during context switch MRS R0, PSP ; PSP is process stack pointer 如果在用PSP堆栈,则可以忽略保存寄存器,参考CM3权威中的双堆栈-白菜注 CBZ R0, PendSV_Handler_Nosave ; Skip register save the first time ;Is the task using the FPU context? If so, push high vfp registers. TST R14, #0x10 IT EQ VSTMDBEQ R0!, {S16-S31} SUBS R0, R0, #0x20 ; Save remaining regs r4-11 on process stack STM R0, {R4-R11} LDR R1, =OSTCBCur ; OSTCBCur->OSTCBStkPtr = SP; LDR R1, [R1] STR R0, [R1] ; R0 is SP of process being switched out ; At this point, entire context of process has been saved PendSV_Handler_Nosave PUSH {R14} ; Save LR exc_return value LDR R0, =OSTaskSwHook ; OSTaskSwHook(); BLX R0 POP {R14} LDR R0, =OSPrioCur ; OSPrioCur = OSPrioHighRdy; LDR R1, =OSPrioHighRdy LDRB R2, [R1] STRB R2, [R0] LDR R0, =OSTCBCur ; OSTCBCur = OSTCBHighRdy; LDR R1, =OSTCBHighRdy LDR R2, [R1] STR R2, [R0] LDR R0, [R2] ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr; LDM R0, {R4-R11} ; Restore r4-11 from new process stack ADDS R0, R0, #0x20 ;Is the task using the FPU context? If so, push high vfp registers. TST R14, #0x10 IT EQ VLDMIAEQ R0!, {S16-S31} MSR PSP, R0 ; Load PSP with new process SP ORR LR, LR, #0x04 ; Ensure exception return uses process stack CPSIE I BX LR ; Exception return will restore remaining context NOP end 2、------------------------------------------------------------ OS_STK *OSTaskStkInit (void (*task)(void *p_arg), void *p_arg, OS_STK *ptos, INT16U opt) { OS_STK *stk; (void)opt; /* 'opt' is not used, prevent warning */ stk = ptos; /* Load stack pointer */ #if (__FPU_PRESENT==1)&&(__FPU_USED==1) *(--stk) = (INT32U)0x00000000L; //No Name Register *(--stk) = (INT32U)0x00001000L; //FPSCR *(--stk) = (INT32U)0x00000015L; //s15 *(--stk) = (INT32U)0x00000014L; //s14 *(--stk) = (INT32U)0x00000013L; //s13 *(--stk) = (INT32U)0x00000012L; //s12 *(--stk) = (INT32U)0x00000011L; //s11 *(--stk) = (INT32U)0x00000010L; //s10 *(--stk) = (INT32U)0x00000009L; //s9 *(--stk) = (INT32U)0x00000008L; //s8 *(--stk) = (INT32U)0x00000007L; //s7 *(--stk) = (INT32U)0x00000006L; //s6 *(--stk) = (INT32U)0x00000005L; //s5 *(--stk) = (INT32U)0x00000004L; //s4 *(--stk) = (INT32U)0x00000003L; //s3 *(--stk) = (INT32U)0x00000002L; //s2 *(--stk) = (INT32U)0x00000001L; //s1 *(--stk) = (INT32U)0x00000000L; //s0 #endif /* Registers stacked as if auto-saved on exception */ *(stk) = (INT32U)0x01000000L; /* xPSR */ *(--stk) = (INT32U)task; /* Entry Point */ *(--stk) = (INT32U)OS_TaskReturn; /* R14 (LR) (init value will cause fault if ever used)*/ *(--stk) = (INT32U)0x12121212L; /* R12 */ *(--stk) = (INT32U)0x03030303L; /* R3 */ *(--stk) = (INT32U)0x02020202L; /* R2 */ *(--stk) = (INT32U)0x01010101L; /* R1 */ *(--stk) = (INT32U)p_arg; /* R0 : argument */ #if (__FPU_PRESENT==1)&&(__FPU_USED==1) *(--stk) = (INT32U)0x00000031L; //s31 *(--stk) = (INT32U)0x00000030L; //s30 *(--stk) = (INT32U)0x00000029L; //s29 *(--stk) = (INT32U)0x00000028L; //s28 *(--stk) = (INT32U)0x00000027L; //s27 *(--stk) = (INT32U)0x00000026L; //s26 *(--stk) = (INT32U)0x00000025L; //s25 *(--stk) = (INT32U)0x00000024L; //s24 *(--stk) = (INT32U)0x00000023L; //s23 *(--stk) = (INT32U)0x00000022L; //s22 *(--stk) = (INT32U)0x00000021L; //s21 *(--stk) = (INT32U)0x00000020L; //s20 *(--stk) = (INT32U)0x00000019L; //s19 *(--stk) = (INT32U)0x00000018L; //s18 *(--stk) = (INT32U)0x00000017L; //s17 *(--stk) = (INT32U)0x00000016L; //s16 #endif /* Remaining registers saved on process stack */ *(--stk) = (INT32U)0x11111111L; /* R11 */ *(--stk) = (INT32U)0x10101010L; /* R10 */ *(--stk) = (INT32U)0x09090909L; /* R9 */ *(--stk) = (INT32U)0x08080808L; /* R8 */ *(--stk) = (INT32U)0x07070707L; /* R7 */ *(--stk) = (INT32U)0x06060606L; /* R6 */ *(--stk) = (INT32U)0x05050505L; /* R5 */ *(--stk) = (INT32U)0x04040404L; /* R4 */ return (stk); } 3、keil环境配置和FPU功能也选了 帮帮我吧!!!!!!!!!!!!!!!!!!! |
|
相关推荐
7个回答
|
|
|
8字节对齐,有几个地方要改
|
|
|
|
|
|
|
|
|
|
|
|
你的参考我也看了,没有发现不同,能具体告诉要改哪里吗? 万分感谢!!!
|
|
|
|
|
|
你的参考我也看了,没有发现不同,能具体告诉要改哪里吗? 万分感谢!!!
|
|
|
|
|
|
__align(8) OS_STK START_TASK_STK[START_STK_SIZE];
|
|
|
|
|
|
你好,这是在哪个文件里啊?帮人帮到底吧,谢谢
|
|
|
|
|
|
这是我写的一个应用程序的栈。你申请的时候也这样子对比着写。要不你加我QQ***.
|
|
|
|
|
只有小组成员才能发言,加入小组>>
1022 浏览 1 评论
1852 浏览 0 评论
1833 浏览 1 评论
3258 浏览 5 评论
3585 浏览 9 评论
1025浏览 1评论
1852浏览 1评论
如何知道嵌入式电子控制单元 (ECU) 中的RAM使用情况?
1364浏览 1评论
1855浏览 0评论
1180浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 15:19 , Processed in 0.864040 second(s), Total 86, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
869