论坛中的各位同志:
大家好!
近日,本人在调试超声波模块,遇到了要检测一段高脉冲时间宽度的问题。在网上搜了一圈儿后发现,介绍用输入捕获的人很多。
小弟就试了试,看了
STM32 V3.5库中
tiM 一节的Input Capture 的例子。结果能测得两个上升沿或者两个下降沿之前的时间宽度。
请问各位朋友们:STM32TIMER的输入捕获功能的触发模式,可以上升沿和下降沿同时触发吗?
我看到的V3.5的库中的触发模式中有两个可以都触发的。可是我的Keil4.12自带的库里面,却没有TIM_ICPolarity_BothEdge 这个定义。
输入捕获功能可以设置上升沿和下降沿都进中断吗?
附:TIMER Input Capture 中中断触发方式的宏定义
#define TIM_ICPolarity_Rising ((uint16_t)0x0000) #define TIM_ICPolarity_Falling ((uint16_t)0x0002) #define TIM_ICPolarity_BothEdge ((uint16_t)0x000A) #define IS_TIM_IC_POLARITY(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || ((POLARITY) == TIM_ICPolarity_Falling)) #define IS_TIM_IC_POLARITY_LITE(POLARITY) (((POLARITY) == TIM_ICPolarity_Rising) || ((POLARITY) == TIM_ICPolarity_Falling)|| ((POLARITY) == TIM_ICPolarity_BothEdge))
InputCapture.rar (12.76 KB )