(Kinetis K60) LPTMR 延时

延时函数

void Delay(U32 time)
{
    SIM_SCGC5 |= SIM_SCGC5_LPTIMER_MASK;
    LPTMR0_CMR = time;
    LPTMR0_PSR = LPTMR_PSR_PCS(1) | LPTMR_PSR_PBYP_MASK;  //PCS:01 LPO——1KHz的时钟 PBYP:1
    LPTMR0_CSR = LPTMR_CSR_TEN_MASK; //使能定时器
    while (!(LPTMR0_CSR & LPTMR_CSR_TCF_MASK)); //延时 溢出复位
    LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK; //清零
}

主函数

void main(void)
{

    DisableInterrupts;

    UART4_Init(115200);
    FTM_PWM_Init();
    FTM_INPUT_INIT();   
    EnableInterrupts;

    while(1)
    {
        Delay(1000);
        count1=count;
        count2=count>>8;
        Uart4_SendByte(count2);
        Uart4_SendByte(count1);
        count=0;         
    }
}

其余完全COPY上一篇代码……


1S收到的数据是0x0253
这样可以算出 不进行任何时钟配备 系统的总线时钟是 47.6MHZ(应该是48MHZ)

原文地址:https://www.cnblogs.com/hebaichuanyeah/p/3124144.html