Forum: µC & Digital Electronics STM32F407 TIM5 external Clock/ ChibiOS

von Christina H. (anonym50)

Rate this post
not useful

i want to configure the Timer 5 with an external Clock (Button).

This is my code, but it doesn't work correct:

  GPIOA->MODER |= GPIO_MODER_MODER0_1;   // Enable AF mode for A0
  GPIOA->AFRL = (GPIOA->AFRL & 0xFFFFFFF0) | 0b0010;  // Select AF2 for 
A0 TIM3/4/5)
  RCC->APB1ENR |= RCC_APB1ENR_TIM5EN;           // Enable TIM5 clock
  TIM5->CCMR1 |= TIM_CCMR1_CC1S_0;        // Input mode, map TI1 to IC1
  TIM5->CCER &= ~(TIM_CCER_CC1P | TIM_CCER_CC1NP); // CC1P and CC1NP = 0 
for rising edge
  //TIM5->SMCR |= TIM_SMCR_SMS;                // External clock mode 1
  TIM5->SMCR |= TIM5->SMCR;         // Trigger selection: TI1
  TIM5->PSC = 0;
  TIM5->ARR = 2;
  TIM5->CR1 |= TIM_CR1_CEN;                  // Enable TIM5 counter

Do you have an idea what's wrong?

Kind regards

von Little B. (lil-b)

Rate this post
not useful
I do not use the definitions for initializing my hardware, hence i do 
not know, what they mean.

But: This Line

Christina H. wrote:
> TIM5->SMCR |= TIM5->SMCR;         // Trigger selection: TI1

has no effect. Check, if it is correct!

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.