Author Topic: STM32 Nucleo F446ZE, TIM2 input capture is inconsistent for higher frequency  (Read 1610 times)

0 Members and 1 Guest are viewing this topic.

Offline AshStm32Topic starter

  • Newbie
  • Posts: 2
  • Country: us
I am using Nucleo F446ze board. And trying to measure frequency from one of the GPIO pin(PA1) . I am using waveform generator to send input signal to PA1 pin . I am using TIM2 timer which is set to input capture mode on channel 2. My system clock is set to 180Mhz and APB1 timer clock to 90Mhz.

I want to measure frequency upto 5Mhz from PA1 . when i run timer with prescalar 0 ..i could measure freq upto 150Khz. Over 15Khz the input capture is not consistent.

Could anyone please guide me how so it configure TIM2 to measure frequency from 2Mhz to 5Mhz?

Thanks for help in advance.
 

Offline dgtl

  • Regular Contributor
  • *
  • Posts: 183
  • Country: ee
Use the timer in external clock mode and let it count the number of pulses in a known interval. Either use another timer ISR to fetch the counter timer count at these intervals or even set up a DMA channel with timer trigger to read the data out of the count of the counter timer. Then substract the next measurement value from previous one to get increment rate and calculate frequncy from there.
 

Offline AshStm32Topic starter

  • Newbie
  • Posts: 2
  • Country: us
Thanks for the respond. I set it up TIM2 to external clock and ETR mode 1 and trigger source is on rising edge.

I read the counter value in the main loop . So this is the count at rising pulse I believe. I am searching on web but haven't found any example that uses  timer or DMA channel to get data out of the counter timer to measure freq.

Could you please point me to any example if you know one?

Regards
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf