-
cw32f030c8t6 PA15输入捕获没反应
voidGTIMInit(void){GPIO_InitTypeDefGPIO_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_InitTypeDefGTIM_InitStruct;GTIM_ICInitTypeDefGTIM_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);}voidGTIM2_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);}}PA01GTIM2CH2可以捕获到输入的信号PA15GTIM2CH1信号输入捕获没反应
2023-11-03 0