void TimerInit(void)
{
BCSCTL1 = CALBC1_8MHZ;
DCOCTL = CALDCO_8MHZ;
CCR0 = 1000;
TACTL = TASSEL_1 + MC_1 + TACLR; // ACLK, upmode
while (TAR != countCycle);
}
請問我Timer_A選用ACLK作為時鐘源,以上述函式來說
執行到1000次所需的時間是:
1000*(1/32768)嘛?
但我實際計時卻是17秒左右...
請各位幫忙謝謝!
此帖出自
小平头技术问答
void TimerInit(int countCycle);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
if (CALBC1_8MHZ == 0xFF || CALDCO_8MHZ == 0xFF) // If calibration constants erased
while(1); // do not load, trap CPU!!
BCSCTL1 = CALBC1_8MHZ;
DCOCTL = CALDCO_8MHZ;
P1DIR |= 0x01;
while (1)
{
TimerInit(1000);
P1OUT ^= 0x01;
}
}
void TimerInit(int countCycle)
{
CCR0 = countCycle;
TACTL = TASSEL_1 + MC_1 + TACLR; // ACLK, upmode
while (TAR != countCycle);
}
我有觀看TAR的值有到1000,LED才會轉態一次
一周热门 更多>