[技术问答] m451 PWM1_CH4 捕获不了。

[复制链接]
1109|11
 楼主| libinskk 发表于 2019-1-14 17:14 | 显示全部楼层 |阅读模式
m451 PWM1_CH4 捕获不了。
进入不了这个中断,void PWM1P1_IRQHandler(void)
应该要如何处理?

  1.         /* set PWM1 channel 4 capture configuration */
  2.         PWM_ConfigCaptureChannel(PWM1, 4, 69, 0);

  3.         /* Enable capture falling edge interrupt for PWM1 channel 4 */
  4.         PWM_EnableCaptureInt(PWM1, 4, PWM_CAPTURE_INT_FALLING_LATCH);

  5.         /* Enable PWM1 NVIC interrupt */
  6.         NVIC_EnableIRQ(PWM1P1_IRQn);

  7.         /* Enable Timer for PWM1 channel 2 */
  8.         PWM_Start(PWM1, PWM_CH_4_MASK);

  9.         /* Enable Capture Function for PWM1 channel 4 */
  10.         PWM_EnableCapture(PWM1, PWM_CH_4_MASK);

  11.         /* Enable falling capture reload */
  12.         PWM1->CAPCTL |= PWM_CAPCTL_FCRLDEN4_Msk;
zhuotuzi 发表于 2019-1-16 17:50 | 显示全部楼层
void PWM_EnableCapture(PWM_T *pwm, uint32_t u32ChannelMask);
你怎么三个参数,你搞毛啊。
zhuotuzi 发表于 2019-1-16 17:50 | 显示全部楼层
这个函数原型只有2个参数,后面都没没看。。。反正看到第二个函数,你就错了
 楼主| libinskk 发表于 2019-1-16 19:30 来自手机 | 显示全部楼层
你看错了吧?大兄弟。
zhuotuzi 发表于 2019-1-16 23:53 | 显示全部楼层
libinskk 发表于 2019-1-16 19:30
你看错了吧?大兄弟。

我是从库函数里复制出来的,能错吗?
734774645 发表于 2019-1-17 10:11 | 显示全部楼层
稳稳の幸福 发表于 2019-1-17 23:17 | 显示全部楼层
上面说的很对。
稳稳の幸福 发表于 2019-1-17 23:17 | 显示全部楼层
我记得也是2个参数,你怎么3个
稳稳の幸福 发表于 2019-1-17 23:17 | 显示全部楼层
能编译通过吗
 楼主| libinskk 发表于 2019-1-20 17:22 | 显示全部楼层
zhuotuzi 发表于 2019-1-16 17:50
这个函数原型只有2个参数,后面都没没看。。。反正看到第二个函数,你就错了 ...

这里是有2个函数,1个是2个参数的,1个是3个参数的。大兄弟我编译是可以通过的。

回到问题上来吧。


  1. /**
  2. * [url=home.php?mod=space&uid=247401]@brief[/url] Enable capture of selected channel(s)
  3. * @param[in] pwm The pointer of the specified PWM module
  4. *                - PWM0 : PWM Group 0
  5. *                - PWM1 : PWM Group 1
  6. * @param[in] u32ChannelMask Combination of enabled channels. Each bit corresponds to a channel.
  7. *                           Bit 0 is channel 0, bit 1 is channel 1...
  8. * [url=home.php?mod=space&uid=266161]@return[/url] None
  9. * [url=home.php?mod=space&uid=1543424]@Details[/url] This function is used to enable capture of selected channel(s).
  10. */
  11. void PWM_EnableCapture(PWM_T *pwm, uint32_t u32ChannelMask)
  12. {
  13.     (pwm)->CAPINEN |= u32ChannelMask;
  14.     (pwm)->CAPCTL |= u32ChannelMask;
  15. }

  1. /**
  2. * @brief Enable capture interrupt of selected channel.
  3. * @param[in] pwm The pointer of the specified PWM module
  4. *                - PWM0 : PWM Group 0
  5. *                - PWM1 : PWM Group 1
  6. * @param[in] u32ChannelNum PWM channel number. Valid values are between 0~5
  7. * @param[in] u32Edge Rising or falling edge to latch counter.
  8. *              - \ref PWM_CAPTURE_INT_RISING_LATCH
  9. *              - \ref PWM_CAPTURE_INT_FALLING_LATCH
  10. * @return None
  11. * @details This function is used to enable capture interrupt of selected channel.
  12. */
  13. void PWM_EnableCaptureInt(PWM_T *pwm, uint32_t u32ChannelNum, uint32_t u32Edge)
  14. {
  15.     (pwm)->CAPIEN |= (u32Edge << u32ChannelNum);
  16. }
xinpian101 发表于 2019-1-20 20:06 | 显示全部楼层
现在搞定了没?
xinpian101 发表于 2019-1-20 20:07 | 显示全部楼层
其他通道好使吗,还是只有这一个这么配置不行了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

38

主题

77

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部