Bug in FTM_SetupDualEdgeCapture()

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Bug in FTM_SetupDualEdgeCapture()

968 次查看
markloit
Contributor I

There is a bug in set-up of the input filtering. The function accepts a channel pair number, but this pair number is used as a direct channel number when setting up the filter.

Code currently in SDK 2.5.0 (and earlier)

    /* Input filter available only for channels 0, 1, 2, 3 */
    if (chnlPairNumber < kFTM_Chnl_4)
    {
        reg = base->FILTER;
        reg &= ~(FTM_FILTER_CH0FVAL_MASK << (FTM_FILTER_CH1FVAL_SHIFT * chnlPairNumber));
        reg |= (filterValue << (FTM_FILTER_CH1FVAL_SHIFT * chnlPairNumber));
        base->FILTER = reg;
    }

This is incorrect as the check in the code expects a channel number, not a pair number. The bits in the FILTER register are also for channels not pairs.

My proposed correction is as follows.

    /* Input filter available only for channels 0, 1, 2, 3. Thus pairs 0 & 1 only (channels 0 & 2) */
    if ((chnlPairNumber*2) < kFTM_Chnl_4)
    {
        reg = base->FILTER;
        reg &= ~(FTM_FILTER_CH0FVAL_MASK << (FTM_FILTER_CH1FVAL_SHIFT * (chnlPairNumber*2)));
        reg |= (filterValue << (FTM_FILTER_CH1FVAL_SHIFT * (chnlPairNumber*2)));
        base->FILTER = reg;
    }

This change is in-line with the rest of the code that converts the pair into a channel number when setting the register values.

标记 (1)
0 项奖励
回复
1 回复

826 次查看
jingpan
NXP TechSupport
NXP TechSupport

Hi Mark,

Yes, you are right. Input filter available only for channels 0, 1, 2, 3. This is a bug. I'll report this bug.

Thanks a lot!

Regards,

Jing

0 项奖励
回复