2018-02-20 01:30 AM
Hi,
I have configure the TIM16_CH1N and TIM17_CH1N timers as input capture to PB6 and PB7 pin respectively:
uint8_t Tim16_17_Init ( void )
{ GPIO_InitTypeDef GPIO_InitStructure; NVIC_InitTypeDef NVIC_InitStructure; TIM_ICInitTypeDef TIM_ICInitStructure;/* TIM clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM16 | RCC_APB2Periph_TIM17, ENABLE);
/* GPIOB clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); /* pin configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOB, &GPIO_InitStructure);/* Connect TIMx pins to AFx */
GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_2); GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_2); /* Enable the TIM16 and TIM17 global Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = TIM16_IRQn | TIM17_IRQn; NVIC_InitStructure.NVIC_IRQChannelPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); // Initialize channel 1 TIM_ICInitStructure.TIM_Channel = TIM_Channel_1; TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising; TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI; TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1; TIM_ICInitStructure.TIM_ICFilter = 0x0F; TIM_ICInit(TIM16, &TIM_ICInitStructure); TIM_ICInit(TIM17, &TIM_ICInitStructure); /* Enable the CC1 Interrupt Request */ TIM_ITConfig(TIM16, TIM_IT_CC1, ENABLE); TIM_ITConfig(TIM17, TIM_IT_CC1, ENABLE);return 0;
}but not work!!!
Thanks
2018-02-20 04:54 AM
is there anyone who used these timers as input capture?
thanks
2018-02-20 12:24 PM
The Negated Output channels are NOT inputs.
2018-02-21 01:23 AM
Thank you Clive!