智能车制作

标题: LPT延时不是很准吗。 [打印本页]

作者: 战怺竝!    时间: 2013-3-25 20:06
标题: LPT延时不是很准吗。
{
    /* Make sure the clock to the LPTMR is enabled */
    SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK;
    /* Set the compare value to the number of ms to delay */
    LPTMR0_CMR = ms;
    /* Set up LPTMR to use 1kHz LPO with no prescaler as its clock source */
    LPTMR0_PSR = LPTMR_PSR_PCS(1) | LPTMR_PSR_PBYP_MASK;//选择时钟1KHZ,
    /* Start the timer */
    LPTMR0_CSR = LPTMR_CSR_TEN_MASK;
    /* Wait for counter to reach compare value */
    while (!(LPTMR0_CSR & LPTMR_CSR_TCF_MASK));
    /* Clear Timer Compare Flag */
    LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;
    return;
}
我在main函数中加IO取反,加了一个1ms延时,为什么用示波器测出的频率是165HZ呢,不应该是500HZ吗,有没有试过的

作者: melon_1    时间: 2013-4-30 08:14
示波器也不是很准





欢迎光临 智能车制作 (http://111.231.132.190/) Powered by Discuz! X3.2