μC/OS-II 移植笔记 2(FreeScale 68HCS12 核单片机)
时间:11-20
来源:互联网
点击:
- F80={/*Interrupttable*/
- software_trap63,/*63RESERVED*/
- software_trap62,/*62RESERVED*/
- software_trap61,/*61RESERVED*/
- software_trap60,/*60RESERVED*/
- software_trap59,/*59RESERVED*/
- software_trap58,/*58RESERVED*/
- software_trap57,/*57PWMEmergencyShutdown*/
- software_trap56,/*56PortPInterrupt*/
- software_trap55,/*55CAN4transmit*/
- software_trap54,/*54CAN4receive*/
- software_trap53,/*53CAN4errors*/
- software_trap52,/*52CAN4wake-up*/
- software_trap51,/*51CAN3transmit*/
- software_trap50,/*50CAN3receive*/
- software_trap49,/*49CAN3errors*/
- software_trap48,/*48CAN3wake-up*/
- software_trap47,/*47CAN2transmit*/
- software_trap46,/*46CAN2receive*/
- software_trap45,/*45CAN2errors*/
- software_trap44,/*44CAN2wake-up*/
- software_trap43,/*43CAN1transmit*/
- software_trap42,/*42CAN1receive*/
- software_trap41,/*41CAN1errors*/
- software_trap40,/*40CAN1wake-up*/
- software_trap39,/*39CAN0transmit*/
- software_trap38,/*38CAN0receive*/
- software_trap37,/*37CAN0errors*/
- software_trap36,/*36CAN0wake-up*/
- software_trap35,/*35FLASH*/
- software_trap34,/*34EEPROM*/
- software_trap33,/*33SPI2*/
- software_trap32,/*32SPI1*/
- software_trap31,/*31IICBus*/
- software_trap30,/*30BDLC*/
- software_trap29,/*29CRGSelfClockMode*/
- software_trap28,/*28CRGPLLlock*/
- software_trap27,/*27PulseAccumulatorBOverflow*/
- software_trap26,/*26ModulusDownCounterunderflow*/
- software_trap25,/*25PortH*/
- software_trap24,/*24PortJ*/
- software_trap23,/*23ATD1*/
- software_trap22,/*22ATD0*/
- SCI1_ISR,/*21SC11*/
- SCI0_ISR,/*20SCI0*/
- software_trap19,/*19SPI0*/
- software_trap18,/*18Pulseaccumulatorinputedge*/
- software_trap17,/*17PulseaccumulatorAoverflow*/
- software_trap16,/*16EnhancedCaptureTimerOverflow*/
- software_trap15,/*15EnhancedCaptureTimerchannel7*/
- software_trap14,/*14EnhancedCaptureTimerchannel6*/
- software_trap13,/*13EnhancedCaptureTimerchannel5*/
- software_trap12,/*12EnhancedCaptureTimerchannel4*/
- software_trap11,/*11EnhancedCaptureTimerchannel3*/
- software_trap10,/*10EnhancedCaptureTimerchannel2*/
- software_trap09,/*09EnhancedCaptureTimerchannel1*/
- software_trap08,/*08EnhancedCaptureTimerchannel0*/
- OSTickISR,/*07RealTimeInterrupt*/
- software_trap06,/*06IRQ*/
- software_trap05,/*05XIRQ*/
- OSCtxSw,/*04SWI-BreakpointonHCS12SerialMon.*/
- software_trap03,/*03Unimplementedinstructiontrap*/
- software_trap02,/*02COPfailurereset*/
- software_trap01//,/*01Clockmonitorfailreset*/
- //_Startup/*00Resetvector*/
- };
当我完成全部移植工作并测试通过后,我又重新审视了一遍整个移植过程,发现走了许多弯路。这些弯路基本都是因为我对C编译器的特性,尤其是内联汇编的处理不熟悉造成的。比如中断处理函数,其实可以直接写到 OS_CPU_C.C 中。就可以省略了 vector.c 文件了。其实我一开始也是这样做的,但是最初的中断处理函数混合了C 语句和汇编语句,产生了各种莫名奇妙的错误。比如下面的RTI中断处理函数代码:
- interruptVectorNumber_VrtivoidOSTickISR(void)
- {
- OSIntNesting++;//4~,NotifyuC/OS-IIaboutISR
- if(OSIntNesting==1)
- {
- __asm
- {
- ldxOSTCBCur//3~,OSTCBCur->OSTCBStkPtr=StackPointer
- sts0,x//3~,}
- }
- }
- CRGFLG_RTIF=1;//clearinterruptflag.
- OSTimeTick();//6~+,CalluC/OS-IIstickupdatingfunction
- OSIntExit();//6~+,NotifyuC/OS-IIaboutendofISR
- }
对比后来的汇编代码,其实已经离成功很近了,只要将其中的C 语句全部用汇编写成来大功告成了:
- interruptVectorNumber_VrtivoidOSTickISR(void)
- {
- __asm
- {
- incOSIntNesting
- ldabOSIntNesting
- cmpb#$01
- bneOSTickISR1
- ldxOSTCBCur
- sts0,x
- OSTickISR1:
- BSET_CRGFLG,#128
- jsrOSTimeTick
- jsrOSIntExit
- }
- }
其他的代码也一样,都这样改写后就完全不需要 vector.c 文件了。但这里还是将这些本可以省略掉的代码保留下来了,是想记录下一条真实的探索路程。
μCOS-II移植笔记68HCS12核单片 相关文章:
- μC/OS-II 移植笔记 1(FreeScale 68HCS12 核单片机)(11-20)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)