cancel
Showing results for 
Search instead for 
Did you mean: 

Pullup does not work when setting up for timer input capture

Tobe
Senior III

I have timer 3, that i want to set up for input capture. But when enabling the alternate function. The pullup is not working. Also an external pullup of 10K does not work.

 

GPIO setup:

 

 

 

	// TIM 3 Inputs (Pedal rot - PB5 / Torc PWM - PB1)
	my_GPIO_InitStruct.Pin = GPIO_PIN_5 | GPIO_PIN_1;
	my_GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
	my_GPIO_InitStruct.Pull = GPIO_PULLUP;
	HAL_GPIO_Init(GPIOB, &my_GPIO_InitStruct);
	GPIOC->AFR[0] |= (	GPIO_AFRL_AFSEL1_1 |  	// AF2 (all)
						GPIO_AFRL_AFSEL5_1);

 

 

 

 

Timer setup:

 

 

 

	__disable_irq();
	__HAL_RCC_TIM3_CLK_ENABLE();

	SET_BIT(  TIM3->CCMR1,  TIM_CCMR1_CC2S_0);
	SET_BIT(  TIM3->CCMR2, 	TIM_CCMR2_CC4S_0);	// channel is configured as input, tim_ic1 is mapped on tim_ti1, etc...
	// TODO: filter??
	SET_BIT(  TIM3->CCER,   TIM_CCER_CC2E |
							TIM_CCER_CC2NP |
							TIM_CCER_CC2P |
							TIM_CCER_CC4E |
							TIM_CCER_CC4NP |
							TIM_CCER_CC4P);		//  capture enable and Rising and falling edge

	// TISEL default input channels

	SET_BIT(  TIM3->DIER,   TIM_DIER_CC2IE | TIM_DIER_CC4IE); 	// enable interrupt on signal
	SET_BIT(  TIM3->CR1,    TIM_CR1_CEN); 		// enable counter timer 3

	NVIC_EnableIRQ(TIM3_IRQn);				// enable global interrupt
	SET_BIT(TIM3->EGR, TIM_EGR_CC2G);	//force interrupt
	__enable_irq();

 

 

 

 

I already tried to set CC2E/CC4E a step after CC2NP, ... . It did not work.

1 ACCEPTED SOLUTION

Accepted Solutions
Tobe
Senior III

Oh my....

GPIOC should be GPIOB !!

View solution in original post

1 REPLY 1
Tobe
Senior III

Oh my....

GPIOC should be GPIOB !!