在线时间21 小时
UID2066963
注册时间2016-10-21
NXP金币0
TA的每日心情 | 开心 2020-7-1 10:30 |
---|
签到天数: 5 天 连续签到: 1 天 [LV.2]偶尔看看I
注册会员

- 积分
- 174
- 最后登录
- 2021-11-9
|
以前玩的stm32,最近开始玩的KL系列,发现差距好大
KL25的中断有多难打开啊!
咋配置都没有用
- void echo_input(void)
- {
- const port_pin_config_t portc12_pin88_config = {/* Internal pull-up resistor is enabled */
- kPORT_PullDown, //kPORT_PullUp,
- /* Slow slew rate is configured */
- kPORT_FastSlewRate,
- /* Passive filter is disabled */
- kPORT_PassiveFilterDisable,
- /* Low drive strength is configured */
- kPORT_LowDriveStrength,
- /* Pin is configured as PTC12 */
- kPORT_MuxAsGpio};
- /* PORTC12 (pin 88) is configured as PTC12 */
- PORT_SetPinConfig(ECHO_PORT, ECHO_PINn, &portc12_pin88_config);
-
- /* Define the init structure for the input switch pin */
- gpio_pin_config_t sw_config = {
- kGPIO_DigitalInput, 0,
- };
- PORT_SetPinInterruptConfig(ECHO_PORT, ECHO_PINn, kPORT_InterruptFallingEdge);
- EnableIRQ(ECHO_PORT_IRQn);
-
- GPIO_PinInit(ECHO_GPIO, ECHO_PINn, &sw_config);
- /* Init input switch GPIO. */
- }
复制代码 中断入口
- void PORTD_IRQHandler(void)
- {
- GPIO_ClearPinsInterruptFlags(ECHO_GPIO, 1u<<ECHO_PINn);
- static uint32_t tick_start = 0;
- if(GPIO_ReadPinInput(ECHO_GPIO, ECHO_PINn) == 1)
- {
- tick_start = get_us();
- }
- else
- {
- distance = (get_us()-tick_start)*170/10000;
- }
- #if defined __CORTEX_M && (__CORTEX_M == 4U)
- __DSB();
- #endif
- }
复制代码 就是不进中断
|
|