ARM技术论坛
直播中

默ct

7年用户 58经验值
擅长:模拟技术 光电显示 EDA/IC设计
私信 关注
[问答]

定时器定时时间计算

这是CC2538的定时器例程,定时1s,请问一下这个1s怎么计算的?255那两个地方我感觉怎么改都没啥用,我想定时1分钟应该怎么改程序?有没有哪位大佬帮帮忙的,谢谢
// Set the clocking to run directly from the external crystal/oscillator.
    // (no ext 32k osc, no internal osc)
    //
    SysCtrlClockSet(false, false, SYS_CTRL_SYSDIV_32MHZ);
    //
    // Set IO clock to the same as system clock
    //
    SysCtrlIOClockSet(SYS_CTRL_SYSDIV_32MHZ);   
   
    //
    // The timer0 peripheral must be enabled for use.
    //
    SysCtrlPeripheralEnable(SYS_CTRL_PERIPH_GPT0);
    // Configure GPTimer0B as a 16-bit periodic timer.
    //
    TimerConfigure(GPTIMER0_BASE, GPTIMER_CFG_SPLIT_PAIR |
                   GPTIMER_CFG_A_PERIODIC |GPTIMER_CFG_B_PERIODIC);
    //
    // Configure GPTimer0B clock prescaler for 255. This will make the
    // effective timer clock be SYSCLOCK / 255.
    //
    TimerPrescaleSet(GPTIMER0_BASE, GPTIMER_B, 255);
    //
    // Set the GPTimer0B load value to 1sec by setting the timer load value
    // to SYSCLOCK / 255. This is determined by:
    //      Prescaled clock = 16Mhz / 255
    //      Cycles to wait = 1sec * Prescaled clock
    //
    TimerLoadSet(GPTIMER0_BASE, GPTIMER_B, SysCtrlClockGet() / 255);





更多回帖

发帖
×
20
完善资料,
赚取积分