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.

CC2640R2F GPTimer 回调触发方式



GPTimerCC26XX_registerInterrupt(hTimer, timerCallback, GPT_INT_CAPTURE_MATCH);

/*!
 *  @brief
 *  Definitions for supported GPTimer interrupts. GPTimerCC26XX_IntMask
 *  arguments should be a bit vector containing these definitions.
 *  See description in Technical Reference
 */
typedef enum GPTimerCC26XX_Interrupt
{
    GPT_INT_TIMEOUT           = 1 << 0,
        GPT_INT_CAPTURE_MATCH = 1 << 1,
        GPT_INT_CAPTURE       = 1 << 2,
        GPT_INT_MATCH         = 1 << 3,
} GPTimerCC26XX_Interrupt;

你们好,项目想要实现在单位时间内捕捉电平边缘个数来计算电机转速,但是在触发回调函数的时候遇到了问题。

上述的代码中,GPTimerCC26XX_Interrupt的条件一共有4个,由于文档中对于这几种中断触发模式的描述很少,所以对于后三者的区别我不是很清楚,我很高兴有人能为我解答,谢谢!

  • 技术参考文档中是没有关于这几种中断的详细描述,目前只有这些,我找一下相关的说明,之后回复你

    /*!
     *  @brief  Set GPTimer load value. For 32-bit configuration all 32 bits can
     *          be used. For split mode / 16-bit mode maximum value is 24 bits.
     *          Function concatenates prescaler functionality automatically
     */
    void GPTimerCC26XX_setLoadValue(GPTimerCC26XX_Handle handle, GPTimerCC26XX_Value loadValue)
    {
        GPTimerCC26XXSetLoadMatch(handle, loadValue, GPT_O_TAPR, GPT_O_TAILR);
    }
    
    /*!
     *  @brief  Set GPTimer match value. For 32-bit configuration all 32 bits can
     *          be used. For split mode / 16-bit mode maximum value is 24 bits.
     *          Function concatenates prescaler functionality automatically
     */
    void GPTimerCC26XX_setMatchValue(GPTimerCC26XX_Handle handle, GPTimerCC26XX_Value matchValue)
    {
        GPTimerCC26XXSetLoadMatch(handle, matchValue, GPT_O_TAPMR, GPT_O_TAMATCHR);
    }
    

  • 好的,辛苦你了
  • GPT_INT_CAPTURE_MATCH :match值和capture值相等时触发中断(相当于捕获比较模式中断)
    GPT_INT_CAPTURE :达到设定捕获值时触发中断
    GPT_INT_MATCH : 达到match设定值时触发中断