我想对NST1001传入的脉冲计数,使用示波器可以看到脉冲有发出,但是io口没有进入中断。
GPIO_Mode_AIN = 0x0, GPIO_Mode_IN_FLOATING = 0x04, GPIO_Mode_IPD = 0x28, GPIO_Mode_IPU = 0x48,
这几个模式都试过了。
不知道问题出在哪里,另外我使用按键 EXTI_Line3 是可以正常进入中断的。
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); } }
热门产品 :
CH641: PD及无线充电专用MCU