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.

CC3200 Timer 周期性 定时器



TImer已设置成  周期性 产生 TimeOut中断(比如间隔10s),但特殊情况下,希望Timer 下一次在 第6s时 产生一个TimeOut 中断。 后面又是正常10s 一次中断。

请教一下大家, 该怎么做?

可能需要用到 TimerLoadSet, TimerValueSet

  • 参考Timer例程,进入定时器中断后,修改下一次的定时时间为6s即可,如需要修改为10s在下一次的中断服务函数中修改,可以通过一个标志位来进行区分6s还是10s

    //
    // Initialize board configurations
    BoardInit();
    //
    // Pinmuxing for LEDs
    //
    PinMuxConfig();
    //
    // configure the LED RED and GREEN
    //
    GPIO_IF_LedConfigure(LED1|LED3);

    GPIO_IF_LedOff(MCU_RED_LED_GPIO);
    GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);

    //
    // Base address for first timer
    //
    g_ulBase = TIMERA0_BASE; //定时器0
    //
    // Base address for second timer
    //
    g_ulRefBase = TIMERA1_BASE; //定时器1
    //
    // Configuring the timers
    // TIMER_CFG_PERIODIC-32位宽度 TimerA0/TimerA1的设置值都是TIMER_A 0不分频
    // 注意预分频值只对16位定时器有效,对32位定时器无效!
    // TRM-When using Timer A and Timer B in concatenated mode, only the Timer A control and status bits must be used 当采用32位时仅有TimeA控制标志位有效!因此-->TIMER_A
    Timer_IF_Init(PRCM_TIMERA0, g_ulBase, TIMER_CFG_PERIODIC, TIMER_A, 0); //其实 TIMER_A并未起作用,其传递的函数是分频函数,对32位定时器无效!
    Timer_IF_Init(PRCM_TIMERA1, g_ulRefBase, TIMER_CFG_PERIODIC, TIMER_A, 0);

    //
    // Setup the interrupts for the timer timeouts.
    //
    Timer_IF_IntSetup(g_ulBase, TIMER_A, TimerBaseIntHandler);
    Timer_IF_IntSetup(g_ulRefBase, TIMER_A, TimerRefIntHandler);

    //
    // Turn on the timers feeding values in mSec
    //
    Timer_IF_Start(g_ulBase, TIMER_A, 500);
    Timer_IF_Start(g_ulRefBase, TIMER_A, 1000);