单片机/MCU论坛
直播中

李燕

7年用户 1490经验值
私信 关注
[问答]

M451的GPIO可以设置成脉冲上升沿或下降沿中断吗?

M451的GPIO可以设置成脉冲上升沿或下降沿中断吗?如果识别是哪个中断源呢?有例程吗?

回帖(7)

张丽

2019-1-8 09:10:35
脉冲还有上升沿和下降沿之分吗、?
举报

杨海清

2019-1-8 09:10:45
你那不是脉冲了,是高低电平。你设置成双边沿中断就行了。
举报

贾虎世

2019-1-8 09:11:00
  1. /**
  2. * [url=home.php?mod=space&uid=247401]@brief[/url]       Enable GPIO interrupt
  3. *
  4. * @param[in]   port            GPIO port. It could be PA, PB, PC, PD, PE or PF.
  5. * @param[in]   u32Pin          The pin of specified GPIO port.
  6. *                              It could be 0 ~ 15 for PA, PB, PC and PD GPIO port.
  7. *                              It could be 0 ~ 14 for PE GPIO port.
  8. *                              It could be 0 ~ 7 for PF GPIO port.
  9. * @param[in]   u32IntAttribs   The interrupt attribute of specified GPIO pin. It could be n
  10. *                              GPIO_INT_RISING, GPIO_INT_FALLING, GPIO_INT_BOTH_EDGE, GPIO_INT_HIGH, GPIO_INT_LOW.
  11. *
  12. * [url=home.php?mod=space&uid=266161]@return[/url]      None
  13. *
  14. * [url=home.php?mod=space&uid=1543424]@Details[/url]     This function is used to enable specified GPIO pin interrupt.
  15. */
  16. void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs)
  17. {
  18.     port->INTTYPE |= (((u32IntAttribs >> 24) & 0xFFUL) << u32Pin);
  19.     port->INTEN |= ((u32IntAttribs & 0xFFFFFFUL) << u32Pin);
  20. }
举报

韩刚龙

2019-1-8 09:11:12
GPIO_INT_BOTH_EDGE

采用双边沿。
举报

贾飞世

2019-1-8 09:11:20
你要测一下,看看够不够几个时钟周期。要让单片机能响应的。
举报

贾飞小

2019-1-8 09:11:29
试试上面的,或者最好示波器观察一下。如果是脉冲,宽度可以忽略的,你上升沿跟下降沿不就是同时了吗
举报

李华

2019-1-8 09:11:47
双边沿模式嘛
举报

更多回帖

发帖
×
20
完善资料,
赚取积分