The TIM1 Troubles of STM32F407

Hello~
Please look at the following codes:

[code]//TIM8,PC6 PC7
RCC->APB2ENR |= 1<<1; //TIM8 timer enable
RCC->AHB1ENR |= 1<<2; //GPIO port clock enable

GPIOC->MODER &= 0xFFFF0FFF; //PC6,PC7 set to be reuse pattern
RCC->APB2ENR |= 1<<1;          //TIM8 timer enable
RCC->AHB1ENR |= 1<<2;          //GPIO port clock enable
GPIOC->MODER &= 0xFFFF0FFF;      //PC6,PC7 set to be reuse pattern
GPIOC->MODER |= 0x0000A000;  
 
GPIOC->AFR[0] &= 0x00FFFFFF;
GPIOC->AFR[0] |= 0x33000000;

TIM8->ARR = 0xFFFF;
TIM8->PSC = 0;
 
TIM8->CCMR1 &= 0xFCFC;  //CC1 pass set to be input, IC1 map on TI1 ,CC2  pass set to be input, IC2 map on TI2    TIM8->CCMR1 |= 0x0101;           
 
TIM8->CCER  &= 0xFFDD;
TIM8->CCMR1 &= 0x0F0F;   //no flagging
 
TIM8->SMCR  &= 0xFFF8;
TIM8->SMCR  |= 0x0003;
 
TIM8->CR1 |= 1<<0;     //enable counter

//TIM1,PA8 PA9
RCC->APB2ENR |= 1<<0; //TIM1 timer enable
RCC->AHB1ENR |= 1<<0; //GPIOAport clock enable

GPIOA->MODER &= 0xFFF0FFFF;      //PA8,PA9 set to be reuse pattern
GPIOA->MODER |= 0x000A0000;  
 
GPIOA->AFR[1] &= 0xFFFFFF00;
GPIOA->AFR[1] |= 0x00000011;

TIM1->ARR = 0xFFFF;
TIM1->PSC = 0;
 
TIM1->CCMR1 &= 0xFCFC;  //CC1 pass set to be input, IC1 map on TI1 上,CC2 pass set to be input, IC2 map on  TI2
TIM1->CCMR1 |= 0x0101;           
 
TIM1->CCER  &= 0xFFDD;
TIM1->CCMR1 &= 0x0F0F;   //no flagging
 
TIM1->SMCR  &= 0xFFF8;
TIM1->SMCR  |= 0x0003;

TIM1->CR1 |= 1<<0; //enable counter[/code]

As the codes we can see,TIM8 can counte as normal but TIM1 has no ** count and the DIR changes from up to now. I don’t know if is the USART1_TX of PA9 wrong? Or the reason occurred by hardware–STM32F407 ? Well, this is the datasheet of STM32F407 ,you can see more details about the hardware.
Appreciate a lot !
Regards~

I’m afraid I have no interest in Arduino for ST parts, but I do use STM32 parts extensively. Sometimes I use the ST provided peripheral interface libraries, which for setting up a timer for encoder input works for me as follows:

/*
* Setup the GPIO
*  PB4:  ENCA
*  PB5:  ENCB
*/
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5;
GPIO_Init(GPIOB, &GPIO_InitStructure);

/*
* Route the inputs to TIM3 for encoder operation
*/
GPIO_PinAFConfig(GPIOB, GPIO_PinSource4, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource5, GPIO_AF_2);

/*
* Setup TIM3 to monitor the encoder
*/
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
TIM_InitStructure.TIM_Prescaler = 0;
TIM_InitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_InitStructure.TIM_Period = (-1);
TIM_InitStructure.TIM_ClockDivision = 0;
TIM_InitStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM3, &TIM_InitStructure);

TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 7;
TIM_ICInit(TIM3, &TIM_ICInitStructure);
TIM_ICInitStructure.TIM_Channel = TIM_Channel_2;
TIM_ICInit(TIM3, &TIM_ICInitStructure);

TIM_EncoderInterfaceConfig(TIM3, TIM_EncoderMode_TI12, TIM_ICPolarity_BothEdge, TIM_ICPolarity_BothEdge);

TIM_OC1PolarityConfig(TIM3, TIM_OCPolarity_High);
TIM_OC1NPolarityConfig(TIM3, TIM_OCPolarity_High);
TIM_OC2PolarityConfig(TIM3, TIM_OCPolarity_High);
TIM_OC2NPolarityConfig(TIM3, TIM_OCPolarity_High);
TIM_Cmd(TIM3, ENABLE);

Thank you! You are so kind! @Loveny