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

Author: Christina H. (anonym50)
Posted on:

Rate this post
0 useful
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

Author: Little Basdart (lil-b)
Posted on:

Rate this post
0 useful
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!


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.