This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

调C2000的launchpad遇到一点问题,关于CPU TIMER的,在函数库中有个TIMER_reload()函数。。。

我想用F28027的CPU Timer做一个计时,由外部中断控制计时开始和停止。每次中断后,希望重新开始计数,就是清除当前计数器的计数值,重新载入初始值,我看了一下,这个函数TIMER_reload(),可以自动重新载入初始值,可是为什么我调用了之后,不能在进入中断后就立即载入初始值,貌似要等到当前周期计数完成,才能载入。。。难道是芯片本身决定的,还是我没有配置好?

  • 你好,Shunli

    F28xx系列的Timer都是在完成一整个计数周期之后,才会重新对新的初始值进行载入,这是芯片本身决定的。

    想请教一下,你所提到的TIMER_reload()这个函数的定义是在哪里?

  • 你说的那个TIMER_reload()的函数是写错了的。里面把TRB给清0了,可是这个位是写1才进行reload。

  • timer.c中的TIMER_reload()函数中写:

    // clear the bits
    timer->TCR &= (~(uint32_t)TIMER_TCR_TRB_BITS);

    TRB:

    CPU-Timer Reload bit.
    0 The TRB bit is always read as zero. Writes of 0 are ignored.
    1 When you write a 1 to TRB, the TIMH:TIM is loaded with the value in the PRDH:PRD,
    and the prescaler counter (PSCH:PSC) is loaded with the value in the timer dividedown
    register (TDDRH:TDDR).

    置一才reload,所以例程函数写错了。

  • Yes.

    TIMER_reload in /f2802x_common/source/timer.c clear the TRB bit instead of setting it.
    Replace: timer->TCR &= (~(uint32_t)TIMER_TCR_TRB_BITS);
    With: timer->TCR |= TIMER_TCR_TRB_BITS;

    Have report the bug.

    -Eric

  • f28027库的Timer.c中

  • 嗯,谢谢。当时没有解决掉,后来我换了种方法做的,今天才看到回复