STM32F407 TIM5 external Clock/ ChibiOS

OP #4309695
Rate this post
• ▲ useful
▼ not useful
Hello,

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 |= TIM_SMCR_ECE;
  TIM5->SMCR |= TIM5->SMCR;         // Trigger selection: TI1
  TIM5->PSC = 0;
  TIM5->ARR = 2;
  TIM5->DIER |= TIM_DIER_UIE;
  TIM5->CR1 |= TIM_CR1_CEN;                  // Enable TIM5 counter


Do you have an idea what's wrong?

Kind regards

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.