[技术问答] 关于外部中断奇特现象

[复制链接]
806|12
 楼主| dtmcp 发表于 2020-4-2 13:11 | 显示全部楼层 |阅读模式
我用两路外部中断读取外部的方波信号,用仿真调试可以正常进入中断程序,但是读ISRC寄存器都是0,搞的无法判断中断源,不知大家有没有遇到过
 楼主| dtmcp 发表于 2020-4-2 13:15 | 显示全部楼层
顺便提个醒,原来新唐函数的BUG,害人啊  第15脚应用有风险 ,  IO操源代码如下:if ((i32Bit < 0) || (i32Bit >= 15)),
163605e857481b08ca.png
jasontu 发表于 2020-4-6 09:46 | 显示全部楼层
那個料號?
 楼主| dtmcp 发表于 2020-4-8 10:34 | 显示全部楼层
目前是NUC130的问题,其它没有注意
jasontu 发表于 2020-4-9 07:58 | 显示全部楼层
不会呀,一般port是0-15, 最多16根脚
玛尼玛尼哄 发表于 2020-4-9 09:27 | 显示全部楼层
这个如果不用BIT15很难发现啊。
玛尼玛尼哄 发表于 2020-4-9 09:27 | 显示全部楼层
坑够深,
zhuomuniao110 发表于 2020-4-9 22:14 | 显示全部楼层
楼主,你这个库函数好像很古老啊。
zhuomuniao110 发表于 2020-4-9 22:28 | 显示全部楼层
你去官网下载最新的看看。
zhuomuniao110 发表于 2020-4-9 22:29 | 显示全部楼层
还真是的。
zhuomuniao110 发表于 2020-4-9 22:29 | 显示全部楼层
  1. /**************************************************************************//**
  2. * [url=home.php?mod=space&uid=288409]@file[/url]     gpio.c
  3. * [url=home.php?mod=space&uid=895143]@version[/url]  V3.00
  4. * $Revision: 2 $
  5. * $Date: 15/05/04 3:27p $
  6. * [url=home.php?mod=space&uid=247401]@brief[/url]    GPIO driver source file
  7. *
  8. * @note
  9. * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved.
  10. *****************************************************************************/

  11. #include "NUC100Series.h"

  12. /** @addtogroup Standard_Driver Standard Driver
  13.   @{
  14. */

  15. /** @addtogroup GPIO_Driver GPIO Driver
  16.   @{
  17. */

  18. /** @addtogroup GPIO_EXPORTED_FUNCTIONS GPIO Exported Functions
  19.   @{
  20. */

  21. /**
  22. * @brief       Set GPIO operation mode
  23. *
  24. * @param[in]   port        GPIO port. It could be PA, PB, PC, PD, PE or PF.
  25. * @param[in]   u32PinMask  The single or multiple pins of specified GPIO port.
  26. *                          It could be BIT0 ~ BIT15 for PA, PB, PC, PD and PE GPIO port.
  27. *                          It could be BIT0 ~ BIT3 for PF GPIO port.
  28. * @param[in]   u32Mode     Operation mode. . It could be \n
  29. *                          GPIO_PMD_INPUT, GPIO_PMD_OUTPUT, GPIO_PMD_OPEN_DRAIN, GPIO_PMD_QUASI.
  30. *
  31. * [url=home.php?mod=space&uid=266161]@return[/url]      None
  32. *
  33. * [url=home.php?mod=space&uid=1543424]@Details[/url]     This function is used to set specified GPIO operation mode.
  34. */
  35. void GPIO_SetMode(GPIO_T *port, uint32_t u32PinMask, uint32_t u32Mode)
  36. {
  37.     uint32_t i;

  38.     for(i = 0; i < GPIO_PIN_MAX; i++)
  39.     {
  40.         if(u32PinMask & (1 << i))
  41.         {
  42.             port->PMD = (port->PMD & ~(0x3 << (i << 1))) | (u32Mode << (i << 1));
  43.         }
  44.     }
  45. }

  46. /**
  47. * @brief       Enable GPIO interrupt
  48. *
  49. * @param[in]   port            GPIO port. It could be PA, PB, PC, PD, PE or PF.
  50. * @param[in]   u32Pin          The pin of specified GPIO port.
  51. *                              It could be 0 ~ 15 for PA, PB, PC, PD and PE GPIO port.
  52. *                              It could be 0 ~ 3 for PF GPIO port.
  53. * @param[in]   u32IntAttribs   The interrupt attribute of specified GPIO pin. It could be \n
  54. *                              GPIO_INT_RISING, GPIO_INT_FALLING, GPIO_INT_BOTH_EDGE, GPIO_INT_HIGH, GPIO_INT_LOW.
  55. *
  56. * @return      None
  57. *
  58. * @details     This function is used to enable specified GPIO pin interrupt.
  59. */
  60. void GPIO_EnableInt(GPIO_T *port, uint32_t u32Pin, uint32_t u32IntAttribs)
  61. {
  62.     port->IMD |= (((u32IntAttribs >> 24) & 0xFFUL) << u32Pin);
  63.     port->IEN |= ((u32IntAttribs & 0xFFFFFFUL) << u32Pin);
  64. }


  65. /**
  66. * @brief       Disable GPIO interrupt
  67. *
  68. * @param[in]   port        GPIO port. It could be PA, PB, PC, PD, PE or PF.
  69. * @param[in]   u32Pin      The pin of specified GPIO port.
  70. *                          It could be 0 ~ 15 for PA, PB, PC, PD and PE GPIO port.
  71. *                          It could be 0 ~ 3 for PF GPIO port.
  72. *
  73. * @return      None
  74. *
  75. * @details     This function is used to enable specified GPIO pin interrupt.
  76. */
  77. void GPIO_DisableInt(GPIO_T *port, uint32_t u32Pin)
  78. {
  79.     port->IMD &= ~(1UL << u32Pin);
  80.     port->IEN &= ~((0x00010001UL) << u32Pin);
  81. }


  82. /*@}*/ /* end of group GPIO_EXPORTED_FUNCTIONS */

  83. /*@}*/ /* end of group GPIO_Driver */

  84. /*@}*/ /* end of group Device_Driver */

  85. /*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/

新版的库函数已经没有这个问题了。
zhuomuniao110 发表于 2020-4-9 22:30 | 显示全部楼层
NUC100_120_Series_BSP_CMSIS_V3.00.005.zip (13.42 MB, 下载次数: 0)


zhuomuniao110 发表于 2020-4-9 22:34 | 显示全部楼层
楼主用的那个早就被淘汰了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

36

主题

194

帖子

1

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