搜索
bottom↓
回复: 3

MSP430F5438 ucosII系统,个人修改过的,TICK采用timerB0

[复制链接]

出0入0汤圆

发表于 2013-2-26 11:23:54 | 显示全部楼层 |阅读模式
自己按照自己的习惯修改的,原有工程使用看门狗定时器作为tick,
自己改为Timer0——B0,留出看门狗用。
定时器定时采用ACLK,外部32Khz晶振,约5ms中断定时,采用比较定时实现。这样B1就可以留出来共其他模块使用,但是时钟源还是XT1.
这样也利于低功耗应用。

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

 楼主| 发表于 2013-2-26 11:28:34 | 显示全部楼层
工程文件为:
tick操作
;********************************************************************************************************
;                                              TICK ISR
;
; Description: This ISR handles tick interrupts.  This ISR uses the Watchdog timer as the tick source.
;
; Notes      : 1) The following C pseudo-code describes the operations being performed in the code below.
;
;                 Save all the CPU registers
;                 if (OSIntNesting == 0) {
;                     OSTCBCur->OSTCBStkPtr = SP;
;                     SP                    = OSISRStkPtr;  /* Use the ISR stack from now on           */
;                 }
;                 OSIntNesting++;
;                 Enable interrupt nesting;                 /* Allow nesting of interrupts (if needed) */
;                 Clear the interrupt source;
;                 OSTimeTick();                             /* Call uC/OS-II's tick handler            */
;                 DISABLE general interrupts;               /* Must DI before calling OSIntExit()      */
;                 OSIntExit();
;                 if (OSIntNesting == 0) {
;                     SP = OSTCBHighRdy->OSTCBStkPtr;       /* Restore the current task's stack        */
;                 }
;                 Restore the CPU registers
;                 Return from interrupt.
;
;              2) ALL ISRs should be written like this!
;
;              3) You MUST disable general interrupts BEFORE you call OSIntExit() because an interrupt
;                 COULD occur just as OSIntExit() returns and thus, the new ISR would save the SP of
;                 the ISR stack and NOT the SP of the task stack.  This of course will most likely cause
;                 the code to crash.  By disabling interrupts BEFORE OSIntExit(), interrupts would be
;                 disabled when OSIntExit() would return.  This assumes that you are using OS_CRITICAL_METHOD
;                 #3 (which is the prefered method).
;
;              4) If you DON'T use a separate ISR stack then you don't need to disable general interrupts
;                 just before calling OSIntExit().  The pseudo-code for an ISR would thus look like this:
;
;                 Save all the CPU registers
;                 if (OSIntNesting == 0) {
;                     OSTCBCur->OSTCBStkPtr = SP;
;                 }
;                 OSIntNesting++;
;                 Enable interrupt nesting;                 /* Allow nesting of interrupts (if needed) */
;                 Clear the interrupt source;
;                 OSTimeTick();                             /* Call uC/OS-II's tick handler            */
;                 OSIntExit();
;                 Restore the CPU registers
;                 Return from interrupt.
;********************************************************************************************************

TIMER0_B0_ISR;WDT_ISR                                 ; wd timer ISR
    PUSHM.A     #12, R15
        add.w           #164,&TBCCR0          ; Add offset to CCR0
    BIC.W       #CCIE, TBCCTL0           ; disable wd timer interrupt

    CMP.B       #0, &OSIntNesting       ; if (OSIntNesting == 0)
    JNE         TIMER0_B0_ISR_1

    MOVX.A      &OSTCBCur, R13          ;     save task stack
    MOVX.A      SP, 0(R13)

    MOVX.A      &OSISRStkPtr, SP        ;     load interrupt stack

TIMER0_B0_ISR_1
    INC.B       &OSIntNesting           ; increase OSIntNesting
   
    BIS.W       #CCIE, TBCCTL0           ; enable wd timer interrupt

    EINT                                ; enable general interrupt to allow for interrupt nesting

    CALLA       #OSTimeTick             ; call ticks routine

    DINT                                ; IMPORTANT: disable general interrupt BEFORE calling OSIntExit()

    CALLA       #OSIntExit

    CMP.B       #0, &OSIntNesting       ; if (OSIntNesting == 0)
    JNE         TIMER0_B0_ISR_2

    MOVX.A      &OSTCBHighRdy, R13      ;     restore task stack SP
    MOVX.A      @R13, SP

TIMER0_B0_ISR_2
    POPM.A      #12, R15

    RETI                                ; return from interrupt

;********************************************************************************************************
;                                 WD TIMER INTERRUPT VECTOR ENTRY
;
; Interrupt vectors
;********************************************************************************************************
    COMMON      INTVEC

;    ORG         WDT_VECTOR
;WDT_VEC   DW    WDT_ISR                 ; interrupt vector. Watchdog/Timer, Timer mode
    ORG         TIMER0_B0_VECTOR
    DW                    TIMER0_B0_ISR                 ; interrupt vector. Watchdog/Timer, Timer mode

    END

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

出0入0汤圆

发表于 2013-3-7 15:49:21 | 显示全部楼层
顶起,不知道149能跑起来不??

出0入0汤圆

发表于 2013-3-8 00:10:17 | 显示全部楼层
顶一下!!
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-28 07:15

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表