专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
STM32
求助stm32f407veTIM1输入捕获问题
2019-07-20 08:36
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
STM32/STM8
8482
9
1716
更新中断正常,捕获中断进不去。输入电平为5Vttl
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
9条回答
周浩然
1楼-- · 2019-07-20 09:52
精彩回答 2 元偷偷看……
加载中...
周浩然
2楼-- · 2019-07-20 14:06
//计算PA8-PA11的频率和周期,使用定时器1,168MHz,在这里仅使用了CC1和CC2
void TIM1_Cap_Init(u16 arr,u16 psc)
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE); ///使能TIM1时钟
RCC_APB1PeriphClockCmd(RCC_AHB1Periph_GPIOA ,ENABLE); ///使能GPIOA时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8|GPIO_Pin_9;//GPA8,GPA9用于频率测量
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//复用功能
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; //速度100MHz
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //推挽复用输出
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; //下拉
GPIO_Init(GPIOA,&GPIO_InitStructure); //初始化
/**TIM1 GPIO Configuration
PA8 ------> TIM1_CH1
PA9 ------> TIM1_CH2
PA10 ------> TIM1_CH3
PA11 ------> TIM1_CH4
*/
GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_TIM1); //PA8 复用为TIM1
GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_TIM1); //PA9 复用为TIM1
// GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_TIM1); //PA10 复用为TIM1
// GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_TIM1); //PA11 复用为TIM1
TIM_DeInit(TIM1);
TIM_TimeBaseInitStructure.TIM_Period = arr; //自动重装载值
TIM_TimeBaseInitStructure.TIM_Prescaler=psc; //定时器分频
TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up; //向上计数模式
TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0;//这个参数只对TIM1和TIM8有效,用于PWM波生成
TIM_TimeBaseInit(TIM1,&TIM_TimeBaseInitStructure);//初始化TIM1
//TIM_SelectOutputTrigger(TIM3, TIM_TRGOSource_Update);
//四个通道配置
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0x04;//不滤波
TIM_ICInit(TIM1,&TIM_ICInitStructure);
TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0x04;//不滤波
TIM_ICInit(TIM1,&TIM_ICInitStructure);
// TIM_ICInitStructure.TIM_Channel = TIM_Channel_3;
// TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
// TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
// TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
// TIM_ICInitStructure.TIM_ICFilter = 0x00;//不滤波
// TIM_ICInit(TIM1,&TIM_ICInitStructure);
//
// TIM_ICInitStructure.TIM_Channel = TIM_Channel_4;
// TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
// TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
// TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
// TIM_ICInitStructure.TIM_ICFilter = 0x00;//不滤波
// TIM_ICInit(TIM1,&TIM_ICInitStructure);
//
TIM_ClearITPendingBit(TIM1,TIM_IT_Update|TIM_IT_CC1|TIM_IT_CC2);
TIM_ClearFlag(TIM1,TIM_FLAG_Update|TIM_FLAG_CC1|TIM_FLAG_CC2);
TIM_ITConfig(TIM1,TIM_IT_Update|TIM_IT_CC1|TIM_IT_CC2,ENABLE); //允许定时器1更新中断|TIM_IT_CC3|TIM_IT_CC4
TIM_Cmd(TIM1,ENABLE); //使能定时器1
// TIM_SelectInputTrigger(TIM1, TIM_TS_TI1FP1|TIM_TS_TI2FP2);
NVIC_InitStructure.NVIC_IRQChannel=TIM1_CC_IRQn ; //定时器1输入捕获中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x00; //抢占优先级1
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x05; //子优先级3
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel=TIM1_UP_TIM10_IRQn ; //定时器1更新中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x01; //抢占优先级1
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x04; //子优先级3
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
//定时器1中断服务函数
__IO uint16_t OVERFLOW[2] = {0};
void TIM1_UP_TIM10_IRQHandler(void)
{
frequency[0] ++;
if(TIM_GetITStatus(TIM1,TIM_IT_Update)==SET) //溢出中断
{
if(TIM1_OVERFLOW == 60000)
{
TIM1_OVERFLOW = 0;
}
else
{
TIM1_OVERFLOW++;
}
}
TIM_ClearITPendingBit(TIM1,TIM_IT_Update); //清除中断标志位
}
uint16_t INTERVAL_PERIOD = 256;//选择每多少个周期计算一次频率
uint16_t INTERVAL_PERIOD_COUNT[Frequency_Channel_Count] = {0};//计数达到INTERVAL_PERIOD则计算一次频率
__IO uint8_t TIM_CAPTURE_COUNT[Frequency_Channel_Count] = {0}; //定时器的捕获数(最大值不大于MAX_TIM_COUNT,每次CC输入捕获中断发生时加一)
void TIM1_CC_IRQHandler(void)
{
if((TIM_GetITStatus(TIM1, TIM_IT_CC1)) == SET) //捕获中断通道1
{
frequency[1] ++;
TIM_TIMECOUNT[0][TIM_CAPTURE_COUNT[0]] = TIM1_OVERFLOW;
TIM_TIME[0][TIM_CAPTURE_COUNT[0]] = TIM_GetCapture1(TIM1);
INTERVAL_PERIOD_COUNT[0] ++;
//计算频率
if(INTERVAL_PERIOD_COUNT[0] > INTERVAL_PERIOD)
{
PushCal(enum_Frequency_Cal,TIM_CAPTURE_COUNT[0]+0x0000);
INTERVAL_PERIOD_COUNT[0] = 0;
}
TIM_CAPTURE_COUNT[0] ++;
TIM_CAPTURE_COUNT[0] %= MAX_TIM_COUNT;
// TIM_ClearITPendingBit(TIM1,TIM_IT_CC1); //清除中断标志位
}
if((TIM_GetITStatus(TIM1, TIM_IT_CC2)) == SET) //捕获中断通道2
{
TIM_TIMECOUNT[1][TIM_CAPTURE_COUNT[1]] = TIM1_OVERFLOW;
TIM_TIME[1][TIM_CAPTURE_COUNT[1]] = TIM_GetCapture2(TIM1);
INTERVAL_PERIOD_COUNT[1] ++;
//计算频率
if(INTERVAL_PERIOD_COUNT[1] > INTERVAL_PERIOD)
{
PushCal(enum_Frequency_Cal,TIM_CAPTURE_COUNT[1]+0x1000);
INTERVAL_PERIOD_COUNT[1] = 0;
}
TIM_CAPTURE_COUNT[1] ++;
TIM_CAPTURE_COUNT[1] %= MAX_TIM_COUNT;
// TIM_ClearITPendingBit(TIM1,TIM_IT_CC2); //清除中断标志位
}
/*由于削减了频率计算的组数CC3和CC4被禁用
// if((TIM_GetITStatus(TIM1, TIM_IT_CC3)) == SET) //捕获中断通道3
// {
// TIM_TIMECOUNT[2][TIM_CAPTURE_COUNT[2]] = TIM1_OVERFLOW;
// TIM_TIME[2][TIM_CAPTURE_COUNT[2]] = TIM_GetCapture3(TIM1);
// INTERVAL_PERIOD_COUNT[2] ++;
// //计算频率
// if(INTERVAL_PERIOD_COUNT[2] > INTERVAL_PERIOD)
// {
// PushCal(enum_Frequency_Cal,TIM_CAPTURE_COUNT[2]+0x2000);
// INTERVAL_PERIOD_COUNT[2] = 0;
// }
//
// TIM_CAPTURE_COUNT[2] ++;
// TIM_CAPTURE_COUNT[2] %= MAX_TIM_COUNT;
//
// TIM_ClearITPendingBit(TIM1,TIM_IT_CC3); //清除中断标志位
// }
//
// if((TIM_GetITStatus(TIM1, TIM_IT_CC4)) == SET) //捕获中断通道4
// {
//
// TIM_TIMECOUNT[3][TIM_CAPTURE_COUNT[3]] = TIM1_OVERFLOW;
// TIM_TIME[3][TIM_CAPTURE_COUNT[3]] = TIM_GetCapture4(TIM1);
// INTERVAL_PERIOD_COUNT[3] ++;
// //计算频率
// if(INTERVAL_PERIOD_COUNT[3] > INTERVAL_PERIOD)
// {
// PushCal(enum_Frequency_Cal,TIM_CAPTURE_COUNT[3]+0x3000);
// INTERVAL_PERIOD_COUNT[3] = 0;
// }
//
// TIM_CAPTURE_COUNT[3] ++;
// TIM_CAPTURE_COUNT[3] %= MAX_TIM_COUNT;
// TIM_ClearITPendingBit(TIM1,TIM_IT_CC4); //清除中断标志位
// }
*/
TIM_ClearITPendingBit(TIM1,TIM_IT_CC1|TIM_IT_CC2); //清除中断标志位
}
加载中...
周浩然
3楼-- · 2019-07-20 16:01
精彩回答 2 元偷偷看……
加载中...
周浩然
4楼-- · 2019-07-20 20:05
还有一个小问题,官方所说的将STM32F2/F4 ART 配置为启用数据缓存 + 指令缓存,禁用预取,这个怎么配置呢
加载中...
STM32歌者
5楼-- · 2019-07-20 20:28
不太懂输入捕获,不过你 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//复用功能 这句不应该这样写吗? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
加载中...
周浩然
6楼-- · 2019-07-21 00:14
精彩回答 2 元偷偷看……
加载中...
1
2
下一页
一周热门
更多
>
相关问题
STM32F4上I2C(在PROTEUS中模拟)调试不通的问题
6 个回答
芯片供应紧张,准备换个MCU,MM32L系列替换STM32L系列的怎么样?
7 个回答
STM32同时使用两个串口进行数据收发时数据丢包的问题
5 个回答
STM32F103串口通信死机问题
4 个回答
STM32WLE5CC连接SX1268在LoRa模式下能与 SX1278互通吗?
2 个回答
STM32开发板免费用活动
7 个回答
stm32 处理 DHT11占用太多时间,大家程序是怎么设计的
8 个回答
分享一个STM32单片机做的离线编程器代码
9 个回答
相关文章
ST公司第一款无线低功耗单片机模块有效提高物联网设计生产效率
0个评论
如何实现对单片机寄存器的访问
0个评论
通过USB用STM32片内自带Bootloader下载程序及注意事项
0个评论
欲练此功必先自宫之STM32汇编启动,放慢是为了更好的前行
0个评论
×
关闭
采纳回答
向帮助了您的网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
STM32
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
关闭
您已邀请
15
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
void TIM1_Cap_Init(u16 arr,u16 psc)
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
TIM_ICInitTypeDef TIM_ICInitStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1,ENABLE); ///使能TIM1时钟
RCC_APB1PeriphClockCmd(RCC_AHB1Periph_GPIOA ,ENABLE); ///使能GPIOA时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8|GPIO_Pin_9;//GPA8,GPA9用于频率测量
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;//复用功能
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; //速度100MHz
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; //推挽复用输出
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; //下拉
GPIO_Init(GPIOA,&GPIO_InitStructure); //初始化
/**TIM1 GPIO Configuration
PA8 ------> TIM1_CH1
PA9 ------> TIM1_CH2
PA10 ------> TIM1_CH3
PA11 ------> TIM1_CH4
*/
GPIO_PinAFConfig(GPIOA,GPIO_PinSource8,GPIO_AF_TIM1); //PA8 复用为TIM1
GPIO_PinAFConfig(GPIOA,GPIO_PinSource9,GPIO_AF_TIM1); //PA9 复用为TIM1
// GPIO_PinAFConfig(GPIOA,GPIO_PinSource10,GPIO_AF_TIM1); //PA10 复用为TIM1
// GPIO_PinAFConfig(GPIOA,GPIO_PinSource11,GPIO_AF_TIM1); //PA11 复用为TIM1
TIM_DeInit(TIM1);
TIM_TimeBaseInitStructure.TIM_Period = arr; //自动重装载值
TIM_TimeBaseInitStructure.TIM_Prescaler=psc; //定时器分频
TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up; //向上计数模式
TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1;
TIM_TimeBaseInitStructure.TIM_RepetitionCounter = 0;//这个参数只对TIM1和TIM8有效,用于PWM波生成
TIM_TimeBaseInit(TIM1,&TIM_TimeBaseInitStructure);//初始化TIM1
//TIM_SelectOutputTrigger(TIM3, TIM_TRGOSource_Update);
//四个通道配置
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0x04;//不滤波
TIM_ICInit(TIM1,&TIM_ICInitStructure);
TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0x04;//不滤波
TIM_ICInit(TIM1,&TIM_ICInitStructure);
// TIM_ICInitStructure.TIM_Channel = TIM_Channel_3;
// TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
// TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
// TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
// TIM_ICInitStructure.TIM_ICFilter = 0x00;//不滤波
// TIM_ICInit(TIM1,&TIM_ICInitStructure);
//
// TIM_ICInitStructure.TIM_Channel = TIM_Channel_4;
// TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
// TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
// TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
// TIM_ICInitStructure.TIM_ICFilter = 0x00;//不滤波
// TIM_ICInit(TIM1,&TIM_ICInitStructure);
//
TIM_ClearITPendingBit(TIM1,TIM_IT_Update|TIM_IT_CC1|TIM_IT_CC2);
TIM_ClearFlag(TIM1,TIM_FLAG_Update|TIM_FLAG_CC1|TIM_FLAG_CC2);
TIM_ITConfig(TIM1,TIM_IT_Update|TIM_IT_CC1|TIM_IT_CC2,ENABLE); //允许定时器1更新中断|TIM_IT_CC3|TIM_IT_CC4
TIM_Cmd(TIM1,ENABLE); //使能定时器1
// TIM_SelectInputTrigger(TIM1, TIM_TS_TI1FP1|TIM_TS_TI2FP2);
NVIC_InitStructure.NVIC_IRQChannel=TIM1_CC_IRQn ; //定时器1输入捕获中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x00; //抢占优先级1
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x05; //子优先级3
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel=TIM1_UP_TIM10_IRQn ; //定时器1更新中断
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x01; //抢占优先级1
NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x04; //子优先级3
NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
//定时器1中断服务函数
__IO uint16_t OVERFLOW[2] = {0};
void TIM1_UP_TIM10_IRQHandler(void)
{
frequency[0] ++;
if(TIM_GetITStatus(TIM1,TIM_IT_Update)==SET) //溢出中断
{
if(TIM1_OVERFLOW == 60000)
{
TIM1_OVERFLOW = 0;
}
else
{
TIM1_OVERFLOW++;
}
}
TIM_ClearITPendingBit(TIM1,TIM_IT_Update); //清除中断标志位
}
uint16_t INTERVAL_PERIOD = 256;//选择每多少个周期计算一次频率
uint16_t INTERVAL_PERIOD_COUNT[Frequency_Channel_Count] = {0};//计数达到INTERVAL_PERIOD则计算一次频率
__IO uint8_t TIM_CAPTURE_COUNT[Frequency_Channel_Count] = {0}; //定时器的捕获数(最大值不大于MAX_TIM_COUNT,每次CC输入捕获中断发生时加一)
void TIM1_CC_IRQHandler(void)
{
if((TIM_GetITStatus(TIM1, TIM_IT_CC1)) == SET) //捕获中断通道1
{
frequency[1] ++;
TIM_TIMECOUNT[0][TIM_CAPTURE_COUNT[0]] = TIM1_OVERFLOW;
TIM_TIME[0][TIM_CAPTURE_COUNT[0]] = TIM_GetCapture1(TIM1);
INTERVAL_PERIOD_COUNT[0] ++;
//计算频率
if(INTERVAL_PERIOD_COUNT[0] > INTERVAL_PERIOD)
{
PushCal(enum_Frequency_Cal,TIM_CAPTURE_COUNT[0]+0x0000);
INTERVAL_PERIOD_COUNT[0] = 0;
}
TIM_CAPTURE_COUNT[0] ++;
TIM_CAPTURE_COUNT[0] %= MAX_TIM_COUNT;
// TIM_ClearITPendingBit(TIM1,TIM_IT_CC1); //清除中断标志位
}
if((TIM_GetITStatus(TIM1, TIM_IT_CC2)) == SET) //捕获中断通道2
{
TIM_TIMECOUNT[1][TIM_CAPTURE_COUNT[1]] = TIM1_OVERFLOW;
TIM_TIME[1][TIM_CAPTURE_COUNT[1]] = TIM_GetCapture2(TIM1);
INTERVAL_PERIOD_COUNT[1] ++;
//计算频率
if(INTERVAL_PERIOD_COUNT[1] > INTERVAL_PERIOD)
{
PushCal(enum_Frequency_Cal,TIM_CAPTURE_COUNT[1]+0x1000);
INTERVAL_PERIOD_COUNT[1] = 0;
}
TIM_CAPTURE_COUNT[1] ++;
TIM_CAPTURE_COUNT[1] %= MAX_TIM_COUNT;
// TIM_ClearITPendingBit(TIM1,TIM_IT_CC2); //清除中断标志位
}
/*由于削减了频率计算的组数CC3和CC4被禁用
// if((TIM_GetITStatus(TIM1, TIM_IT_CC3)) == SET) //捕获中断通道3
// {
// TIM_TIMECOUNT[2][TIM_CAPTURE_COUNT[2]] = TIM1_OVERFLOW;
// TIM_TIME[2][TIM_CAPTURE_COUNT[2]] = TIM_GetCapture3(TIM1);
// INTERVAL_PERIOD_COUNT[2] ++;
// //计算频率
// if(INTERVAL_PERIOD_COUNT[2] > INTERVAL_PERIOD)
// {
// PushCal(enum_Frequency_Cal,TIM_CAPTURE_COUNT[2]+0x2000);
// INTERVAL_PERIOD_COUNT[2] = 0;
// }
//
// TIM_CAPTURE_COUNT[2] ++;
// TIM_CAPTURE_COUNT[2] %= MAX_TIM_COUNT;
//
// TIM_ClearITPendingBit(TIM1,TIM_IT_CC3); //清除中断标志位
// }
//
// if((TIM_GetITStatus(TIM1, TIM_IT_CC4)) == SET) //捕获中断通道4
// {
//
// TIM_TIMECOUNT[3][TIM_CAPTURE_COUNT[3]] = TIM1_OVERFLOW;
// TIM_TIME[3][TIM_CAPTURE_COUNT[3]] = TIM_GetCapture4(TIM1);
// INTERVAL_PERIOD_COUNT[3] ++;
// //计算频率
// if(INTERVAL_PERIOD_COUNT[3] > INTERVAL_PERIOD)
// {
// PushCal(enum_Frequency_Cal,TIM_CAPTURE_COUNT[3]+0x3000);
// INTERVAL_PERIOD_COUNT[3] = 0;
// }
//
// TIM_CAPTURE_COUNT[3] ++;
// TIM_CAPTURE_COUNT[3] %= MAX_TIM_COUNT;
// TIM_ClearITPendingBit(TIM1,TIM_IT_CC4); //清除中断标志位
// }
*/
TIM_ClearITPendingBit(TIM1,TIM_IT_CC1|TIM_IT_CC2); //清除中断标志位
}
一周热门 更多>