问答

汇集网友智慧,解决技术难题

yanhh1

TA的家园币:10  

  • 国民技术 N32G455 TIM1 输入捕获 误触发

    大家好:我使用国民技术的N32G455这款单片机的TM1//TIM_CH_4做输入捕获,频率17~32K。设置是下降沿触发,但有时候上升沿也会触发,这是什么原因呢?voidpwm_int(void){GPIO_InitStructure.Pin=GPIO_PIN_11;//TIM1_CH4GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_InitPeripheral(GPIOA,&GPIO_InitStructure);GPIO_InitStructure.Pin=GPIO_PIN_9;//TIM1_CH2GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_InitPeripheral(GPIOA,&GPIO_InitStructure);NVIC_InitTypeNVIC_InitStructure;ADTIMClockFrequency=(GET_RCC_Clocks_Pclk2Freq(TIM1));NVIC_InitStructure.NVIC_IRQChannel=TIM1_CC_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;NVIC_InitStructure.NVIC_IRQChannelSubPriority=1;NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;NVIC_Init(&NVIC_InitStructure);NVIC_InitStructure.NVIC_IRQChannel=TIM1_UP_IRQn;NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;NVIC_InitStructure.NVIC_IRQChannelSubPriority=0;NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;NVIC_Init(&NVIC_InitStructure);#if1TimerPeriod=(ADTIMClockFrequency/33000)-1;/*ComputeCCDAT1valuetogenerateadutycycleat50%forchannel1*/Channel1Pulse=(uint16_t)(((uint32_t)5*(TimerPeriod-1))/10);TIM_TimeBaseStructure1.Prescaler=0;TIM_TimeBaseStructure1.CntMode=TIM_CNT_MODE_UP;TIM_TimeBaseStructure1.Period=TimerPeriod;TIM_TimeBaseStructure1.ClkDiv=0;TIM_TimeBaseStructure1.RepetCnt=0;TIM_InitTimeBase(TIM1,&TIM_TimeBaseStructure1);#endifTIM_ICInitStructure.Channel=TIM_CH_2;TIM_ICInitStructure.IcPolarity=TIM_IC_POLARITY_RISING;TIM_ICInitStructure.IcSelecti

    2024-12-10 0