查看: 2967|回复: 1

[求助] KL25/KL26 之GPIO中断打不开

[复制链接]
  • TA的每日心情
    开心
    2020-7-1 10:30
  • 签到天数: 5 天

    连续签到: 1 天

    [LV.2]偶尔看看I

    5

    主题

    34

    帖子

    1

    注册会员

    Rank: 2

    积分
    174
    最后登录
    2021-11-9
    发表于 2020-7-4 09:20:42 | 显示全部楼层 |阅读模式
    以前玩的stm32,最近开始玩的KL系列,发现差距好大
    KL25的中断有多难打开啊!
    咋配置都没有用
    1. void echo_input(void)
    2. {
    3.     const port_pin_config_t portc12_pin88_config = {/* Internal pull-up resistor is enabled */
    4.                                                   kPORT_PullDown, //kPORT_PullUp,
    5.                                                   /* Slow slew rate is configured */
    6.                                                   kPORT_FastSlewRate,
    7.                                                   /* Passive filter is disabled */
    8.                                                   kPORT_PassiveFilterDisable,
    9.                                                   /* Low drive strength is configured */
    10.                                                   kPORT_LowDriveStrength,
    11.                                                   /* Pin is configured as PTC12 */
    12.                                                   kPORT_MuxAsGpio};
    13.     /* PORTC12 (pin 88) is configured as PTC12 */
    14.     PORT_SetPinConfig(ECHO_PORT, ECHO_PINn, &portc12_pin88_config);
    15.                                                   
    16.     /* Define the init structure for the input switch pin */
    17.     gpio_pin_config_t sw_config = {
    18.         kGPIO_DigitalInput, 0,
    19.     };

    20. PORT_SetPinInterruptConfig(ECHO_PORT, ECHO_PINn, kPORT_InterruptFallingEdge);
    21. EnableIRQ(ECHO_PORT_IRQn);
    22.    
    23.     GPIO_PinInit(ECHO_GPIO, ECHO_PINn, &sw_config);
    24.     /* Init input switch GPIO. */   
    25. }
    复制代码
    中断入口
    1. void PORTD_IRQHandler(void)
    2. {
    3.   GPIO_ClearPinsInterruptFlags(ECHO_GPIO, 1u<<ECHO_PINn);
    4.   static uint32_t tick_start = 0;
    5.   if(GPIO_ReadPinInput(ECHO_GPIO, ECHO_PINn) == 1)
    6.   {
    7.     tick_start = get_us();
    8.   }
    9.   else
    10.   {
    11.     distance = (get_us()-tick_start)*170/10000;
    12.   }

    13. #if defined __CORTEX_M && (__CORTEX_M == 4U)
    14.     __DSB();
    15. #endif

    16. }
    复制代码
    就是不进中断
    我知道答案 目前已有1人回答

    uart_polling.zip

    2.73 KB, 下载次数: 1, 下载积分: 威望 1

    打卡打卡!今天天气不好!
    回复

    使用道具 举报

  • TA的每日心情
    开心
    2020-7-1 10:30
  • 签到天数: 5 天

    连续签到: 1 天

    [LV.2]偶尔看看I

    5

    主题

    34

    帖子

    1

    注册会员

    Rank: 2

    积分
    174
    最后登录
    2021-11-9
     楼主| 发表于 2020-7-4 10:58:57 | 显示全部楼层
    用A口,好了
    打卡打卡!今天天气不好!
    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /3 下一条

    Archiver|手机版|小黑屋|恩智浦技术社区

    GMT+8, 2025-7-23 21:15 , Processed in 0.091025 second(s), 22 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.

    快速回复 返回顶部 返回列表