我想對(duì)NST1001傳入的脈沖計(jì)數(shù),使用示波器可以看到脈沖有發(fā)出,但是io口沒有進(jìn)入中斷。
????GPIO_Mode_AIN?=?0x0, ????GPIO_Mode_IN_FLOATING?=?0x04, ????GPIO_Mode_IPD?=?0x28, ????GPIO_Mode_IPU?=?0x48,
這幾個(gè)模式都試過了。
不知道問題出在哪里,另外我使用按鍵?EXTI_Line3 是可以正常進(jìn)入中斷的。
int32_t?nstcount?=?0; void?NST1001_Init(void) { ????GPIO_InitTypeDef?GPIO_InitStructure?=?{0}; ????EXTI_InitTypeDef?EXTI_InitStruct?=?{0}; ????NVIC_InitTypeDef?NVIC_InitStruct?=?{0}; ????RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,?ENABLE); ????GPIO_InitStructure.GPIO_Pin?=?GPIO_Pin_0; ????GPIO_InitStructure.GPIO_Mode?=?GPIO_Mode_IPU; ????GPIO_Init(GPIOD,?&GPIO_InitStructure); ????GPIO_EXTILineConfig(GPIO_PortSourceGPIOD,?GPIO_PinSource0); ????EXTI_InitStruct.EXTI_Line?=?EXTI_Line0; ????EXTI_InitStruct.EXTI_Mode?=?EXTI_Mode_Interrupt; ????EXTI_InitStruct.EXTI_Trigger?=?EXTI_Trigger_Falling; ????EXTI_InitStruct.EXTI_LineCmd?=?ENABLE; ????EXTI_Init(&EXTI_InitStruct); ????NVIC_InitStruct.NVIC_IRQChannel?=?EXTI7_0_IRQn; ????NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority?=?1; ????NVIC_InitStruct.NVIC_IRQChannelSubPriority?=?0; ????NVIC_InitStruct.NVIC_IRQChannelCmd?=?ENABLE; ????NVIC_Init(&NVIC_InitStruct); }
int?main(void) { ????NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); ????SystemCoreClockUpdate(); ????Delay_Init(); #if?(SDI_PRINT?==?SDI_PR_OPEN) ????SDI_Printf_Enable(); #else ????USART_Printf_Init(115200); #endif ????printf("SystemClk:%d\r\n",SystemCoreClock); ????printf(?"ChipID:%08x\r\n",?DBGMCU_GetCHIPID()?); ????USARTx_CFG(); ????NST1001_Init(); ????//Key_Init(); ????while(1) ????{ ????????nstcount?++; ????????Delay_Ms(1000); ????????printf("%ld\r\n",?nstcount); ????} } void?EXTI7_0_IRQHandler(void)?__attribute__((interrupt("WCH-Interrupt-fast"))); /*** ?* ?*??ж? ?*/ void?EXTI7_0_IRQHandler(void) { ????//printf("interrupt\r\n"); ????if?(EXTI_GetITStatus(EXTI_Line0)) ????{ ????????printf("key\r\n"); ????????nstcount?+=20; ????????EXTI_ClearITPendingBit(EXTI_Line0); ????} ????else?if?(EXTI_GetITStatus(EXTI_Line3)) ????{ ????????printf("key\r\n"); ????????nstcount?+=20; ????????EXTI_ClearITPendingBit(EXTI_Line3); ????} }
熱門產(chǎn)品 :
USB3.0 HUB控制器:CH634