微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > μC/OS-II 移植笔记 2(FreeScale 68HCS12 核单片机)

μC/OS-II 移植笔记 2(FreeScale 68HCS12 核单片机)

时间:11-20 来源:互联网 点击:

  1. F80={/*Interrupttable*/
  2. software_trap63,/*63RESERVED*/
  3. software_trap62,/*62RESERVED*/
  4. software_trap61,/*61RESERVED*/
  5. software_trap60,/*60RESERVED*/
  6. software_trap59,/*59RESERVED*/
  7. software_trap58,/*58RESERVED*/
  8. software_trap57,/*57PWMEmergencyShutdown*/
  9. software_trap56,/*56PortPInterrupt*/
  10. software_trap55,/*55CAN4transmit*/
  11. software_trap54,/*54CAN4receive*/
  12. software_trap53,/*53CAN4errors*/
  13. software_trap52,/*52CAN4wake-up*/
  14. software_trap51,/*51CAN3transmit*/
  15. software_trap50,/*50CAN3receive*/
  16. software_trap49,/*49CAN3errors*/
  17. software_trap48,/*48CAN3wake-up*/
  18. software_trap47,/*47CAN2transmit*/
  19. software_trap46,/*46CAN2receive*/
  20. software_trap45,/*45CAN2errors*/
  21. software_trap44,/*44CAN2wake-up*/
  22. software_trap43,/*43CAN1transmit*/
  23. software_trap42,/*42CAN1receive*/
  24. software_trap41,/*41CAN1errors*/
  25. software_trap40,/*40CAN1wake-up*/
  26. software_trap39,/*39CAN0transmit*/
  27. software_trap38,/*38CAN0receive*/
  28. software_trap37,/*37CAN0errors*/
  29. software_trap36,/*36CAN0wake-up*/
  30. software_trap35,/*35FLASH*/
  31. software_trap34,/*34EEPROM*/
  32. software_trap33,/*33SPI2*/
  33. software_trap32,/*32SPI1*/
  34. software_trap31,/*31IICBus*/
  35. software_trap30,/*30BDLC*/
  36. software_trap29,/*29CRGSelfClockMode*/
  37. software_trap28,/*28CRGPLLlock*/
  38. software_trap27,/*27PulseAccumulatorBOverflow*/
  39. software_trap26,/*26ModulusDownCounterunderflow*/
  40. software_trap25,/*25PortH*/
  41. software_trap24,/*24PortJ*/
  42. software_trap23,/*23ATD1*/
  43. software_trap22,/*22ATD0*/
  44. SCI1_ISR,/*21SC11*/
  45. SCI0_ISR,/*20SCI0*/
  46. software_trap19,/*19SPI0*/
  47. software_trap18,/*18Pulseaccumulatorinputedge*/
  48. software_trap17,/*17PulseaccumulatorAoverflow*/
  49. software_trap16,/*16EnhancedCaptureTimerOverflow*/
  50. software_trap15,/*15EnhancedCaptureTimerchannel7*/
  51. software_trap14,/*14EnhancedCaptureTimerchannel6*/
  52. software_trap13,/*13EnhancedCaptureTimerchannel5*/
  53. software_trap12,/*12EnhancedCaptureTimerchannel4*/
  54. software_trap11,/*11EnhancedCaptureTimerchannel3*/
  55. software_trap10,/*10EnhancedCaptureTimerchannel2*/
  56. software_trap09,/*09EnhancedCaptureTimerchannel1*/
  57. software_trap08,/*08EnhancedCaptureTimerchannel0*/
  58. OSTickISR,/*07RealTimeInterrupt*/
  59. software_trap06,/*06IRQ*/
  60. software_trap05,/*05XIRQ*/
  61. OSCtxSw,/*04SWI-BreakpointonHCS12SerialMon.*/
  62. software_trap03,/*03Unimplementedinstructiontrap*/
  63. software_trap02,/*02COPfailurereset*/
  64. software_trap01//,/*01Clockmonitorfailreset*/
  65. //_Startup/*00Resetvector*/
  66. };

后记:
当我完成全部移植工作并测试通过后,我又重新审视了一遍整个移植过程,发现走了许多弯路。这些弯路基本都是因为我对C编译器的特性,尤其是内联汇编的处理不熟悉造成的。比如中断处理函数,其实可以直接写到 OS_CPU_C.C 中。就可以省略了 vector.c 文件了。其实我一开始也是这样做的,但是最初的中断处理函数混合了C 语句和汇编语句,产生了各种莫名奇妙的错误。比如下面的RTI中断处理函数代码:

  1. interruptVectorNumber_VrtivoidOSTickISR(void)
  2. {
  3. OSIntNesting++;//4~,NotifyuC/OS-IIaboutISR
  4. if(OSIntNesting==1)
  5. {
  6. __asm
  7. {
  8. ldxOSTCBCur//3~,OSTCBCur->OSTCBStkPtr=StackPointer
  9. sts0,x//3~,}
  10. }
  11. }
  12. CRGFLG_RTIF=1;//clearinterruptflag.
  13. OSTimeTick();//6~+,CalluC/OS-IIstickupdatingfunction
  14. OSIntExit();//6~+,NotifyuC/OS-IIaboutendofISR
  15. }

对比后来的汇编代码,其实已经离成功很近了,只要将其中的C 语句全部用汇编写成来大功告成了:

  1. interruptVectorNumber_VrtivoidOSTickISR(void)
  2. {
  3. __asm
  4. {
  5. incOSIntNesting
  6. ldabOSIntNesting
  7. cmpb#$01
  8. bneOSTickISR1
  9. ldxOSTCBCur
  10. sts0,x
  11. OSTickISR1:
  12. BSET_CRGFLG,#128
  13. jsrOSTimeTick
  14. jsrOSIntExit
  15. }
  16. }

其他的代码也一样,都这样改写后就完全不需要 vector.c 文件了。但这里还是将这些本可以省略掉的代码保留下来了,是想记录下一条真实的探索路程。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top