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 定时器 每秒产生一次中断

Other Parts Discussed in Thread: CC3200

请教一下TI的工程师, 

CC3200 定时器可以每秒产生一次中断吗? 我想简单维持一个 时间(每10分钟从服务器获取正确时间,进行校准)

比如,希望执行一个功能, 5s后,再继续执行另一个功能。

因为程序中,有网络接收,和几个Task, 所有这个时间定时器中断应简单点,只处理每秒的中断函数, 其他时间碎片 交给其他Task处理。

不考虑功耗

  • 参考官方的Timer例程

    //
    // 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);

    //*****************************************************************************
    //
    //! The interrupt handler for the first timer interrupt.
    //!
    //! \param None
    //!
    //! \return none
    //
    //*****************************************************************************
    void
    TimerBaseIntHandler(void)
    {
    //
    // Clear the timer interrupt.
    //
    Timer_IF_InterruptClear(g_ulBase);

    g_ulTimerInts ++;
    GPIO_IF_LedToggle(MCU_GREEN_LED_GPIO);
    }

    //*****************************************************************************
    //
    //! The interrupt handler for the second timer interrupt.
    //!
    //! \param None
    //!
    //! \return none
    //
    //*****************************************************************************
    void
    TimerRefIntHandler(void)
    {
    //
    // Clear the timer interrupt.
    //
    Timer_IF_InterruptClear(g_ulRefBase);

    g_ulRefTimerInts ++;
    GPIO_IF_LedToggle(MCU_RED_LED_GPIO);
    }

  • 谢谢回复, 我看到用RTC 实现定时的功能, 会不会更好一点?

    附件是一个demo。

  • 也可以使用RTC,注意外接32768的晶体,用于提供时钟

  • 用的是CC3200模块, 应该有 32768晶振吧?

    https://item.taobao.com/item.htm?spm=a230r.1.14.41.ebb2eb2BtZWVw&id=42127103300&ns=1&abbucket=8#detail

  • 是的, 32768晶振。

  • 谢谢回复。

  • 为什么没有一个RTC的例子了?  

    对于程序生命周期中,一直维持一个 秒级别的中断

    使用 Timer例程, 是不是 对于复杂的程序 不适合?(包含几个Task,1个队列,串口终端, TCP UDP)