21ic问答首页 - cw32f030c8t6 PA15输入捕获没反应
cw32f030c8t6 PA15输入捕获没反应
看不见的尽头2023-11-03
void GTIMInit(void){ GPIO_InitTypeDef GPIO_InitStruct; __RCC_GPIOA_CLK_ENABLE(); GPIO_InitStruct.IT = GPIO_IT_NONE; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pins = GPIO_PIN_15; GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; GPIO_Init(CW_GPIOA, &GPIO_InitStruct); PA15_AFx_GTIM2CH1(); GTIM_InitTypeDef GTIM_InitStruct; GTIM_ICInitTypeDef GTIM_ICInitStruct; __RCC_GTIM2_CLK_ENABLE(); __disable_irq(); NVIC_EnableIRQ(GTIM2_IRQn); __enable_irq(); GTIM_InitStruct.Mode = GTIM_MODE_TIME; GTIM_InitStruct.OneShotMode = GTIM_COUNT_CONTINUE; GTIM_InitStruct.Prescaler = GTIM_PRESCALER_DIV8; GTIM_InitStruct.ReloadValue = 80; GTIM_InitStruct.ToggleOutState = DISABLE; GTIM_TimeBaseInit(CW_GTIM2, >IM_InitStruct); GTIM_ICInitStruct.CHx = GTIM_CHANNEL1; GTIM_ICInitStruct.ICFilter = GTIM_CHx_FILTER_NONE; GTIM_ICInitStruct.ICInvert = GTIM_CHx_INVERT_ON; GTIM_ICInitStruct.ICPolarity = GTIM_ICPolarity_Falling; GTIM_ICInit(CW_GTIM2, >IM_ICInitStruct); GTIM_ITConfig(CW_GTIM2, GTIM_IT_OV | GTIM_IT_CC1, ENABLE); GTIM_Cmd(CW_GTIM2, ENABLE); }void GTIM2_IRQHandler(void){ if (GTIM_GetITStatus(CW_GTIM2, GTIM_IT_OV)){ GTIM_ClearITPendingBit(CW_GTIM2, GTIM_IT_OV); } if (GTIM_GetITStatus(CW_GTIM2, GTIM_IT_CC1)){ GTIM_ClearITPendingBit(CW_GTIM2, GTIM_IT_CC1); }}PA01 GTIM2 CH2 可以捕获到输入的信号PA15 GTIM2 CH1 信号输入捕获没反应
您需要登录后才可以回复 登录 | 注册