osii for msp430 把OSTimeTick 由WDT 换为timerb为什么不行?
之前ticks是由WDT定时器切换的,可以正常运行,现在因为一些原因想换个定时器timerb之前
WDT_ISR ; wd timer ISR
PUSHALL ; push all registers
bic.b #0x01, IE1 ; disable wd timer interrupt
cmp.b #0, &OSIntNesting ; if (OSIntNesting == 0)
jne WDT_ISR_1
mov.w &OSTCBCur, R13 ; save task stack
mov.w SP, 0(R13)
mov.w &OSISRStkPtr, SP ; load interrupt stack
WDT_ISR_1
inc.b &OSIntNesting ; increase OSIntNesting
bis.b #0x01, IE1 ; enable wd timer interrupt
EINT ; enable general interrupt to allow for interrupt nesting
call #OSTimeTick ; call ticks routine
DINT ; disable general interrupt
call #OSIntExit ; call ticks routine
cmp.b #0, &OSIntNesting ; if (OSIntNesting == 0)
jne WDT_ISR_2
mov.w &OSTCBHighRdy, R13 ; restore task stack SP
mov.w @R13, SP
WDT_ISR_2
POPALL ; pop all registers
reti ; return from interrupt
现在改到了timerb
#pragma vector=TIMERB0_VECTOR
__interrupt voidTimer_B (void)
{
OS_CPU_SRcpu_sr;
OS_ENTER_CRITICAL(); /* Tell uC/OS-II that we are starting an ISR */
OSIntNesting++;
OS_EXIT_CRITICAL();
OSTimeTick(); /* Call uC/OS-II's OSTimeTick() */
OSIntExit(); /* Tell uC/OS-II that we are leaving the ISR */
}
但是任务运行不了,是怎么回事?
我对比了一下,除了保存sp之外,基本一致,仿真时可以进入timerb,但是连续运行,有时候会提示cpuoff,但我根本没进入低功耗~
有人换过ticks时钟源麽? 兄弟,你timerb的中断函数这样写os的tick肯定运行不起来。因为IAR编译器会按照它自己的规则回复中断现场,如果你一定想用C写就查查编译器的手册看有没有办法不让编译器保存现场。GCC里我记得可以用__attribute nest 这事我以前做过,用TA0替代WDT,直接修改汇编文件。
需要修改两个地方,1、替换WDT的函数入口,2、修改中断函数内的相应中断允许位。
下面是改为TA0的,你自己和原文件对照下就知道该改哪里了,改为TB中断也很方便。
页:
[1]