ddrv

    1. 不是OSTickISR的问题,这个函数就像你的注释一样非常清晰,一般不会产生问题。 在这个中断里堆栈会产生错位,中断退出后PC不是原来压进去的PC了,也就是说从这个中断出来后不一定会继续去执行产生中断时的语句,有可能转而去执行更高优先级的任务。因此你的程序跑飞问题不是因为这个中断服务程序,而是在中断退出的时候有个需要自己根据不同的CPU及编译器修改的函数:OSIntCtxSw(); A.根据Metroworks 编译器需要把压栈错位4个字节,可参考如下程序: OSIntCtxSw:     ais       #4                       ;  Ignore return address to OSIntCtxSw() and         bra       OSIntCtxSwRtn            ;  return address from call to OSIntExit()   OSCtxSw:     pshh                            ;  Save H register (doesn't get save upon interrupt) OSIntCtxSwRtn     tsx                              ; H:X ← (SP) + 0x0001     pshx                            ; Push (X); SP ← (SP) - 0x0001     pshh     ldx    _OSTCBCur                ;  Point to current task's TCB : .... B.根据Cosmic编译器需要把压栈错位5个字节,可参考如下程序: _OSIntCtxSw:     ais       #5                         ;  Ignore return address to OSIntCtxSw() and     bra       _OSCtxSw_skip_pshh              ;  return address from call to OSIntExit() _OSCtxSw:     pshh                            ;  Save H register (doesn't get save upon interrupt) _OSCtxSw_skip_pshh:     tsx                              ; H:X ← (SP) + 0x0001     pshx                            ; Push (X); SP ← (SP) - 0x0001     pshh     ldx    _OSTCBCur                ;  Point to current task's TCB 以上两种程序是因为编译器在处理函数调用时的压栈方式不同造成的,分别在Codewarrior及WinIDEA中测试通过。

最近访客

< 1/1 >

统计信息

已有48人来访过

  • 芯积分:--
  • 好友:--
  • 主题:--
  • 回复:1

留言

你需要登录后才可以留言 登录 | 注册


现在还没有留言