cancel
Showing results for 
Search instead for 
Did you mean: 

counter clock PWM INPUT

imanpakii
Associate III
Posted on September 20, 2012 at 01:55

Hi every one 

Is anybody know how can i change counter clock i'm using PWM INPUT example 

this quote got from readme file:

 The TIMxCLK frequency is set to SystemCoreClock/4 (Hz), the Prescaler is 0 so the 

counter clock is SystemCoreClock/2 (Hz).

i want to know can we change counter clock and how ?

7 REPLIES 7
Posted on September 20, 2012 at 02:36

Use a timer on APB2

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
imanpakii
Associate III
Posted on September 20, 2012 at 17:05

Thank you 

Could you explain more ?

 

Posted on September 20, 2012 at 18:30

Timers on APB1 are architecturally limited to 84 MHz, as the bus is slower nominally 36-42 MHz across STM32 families.

The APB2 bus is faster (84 MHz), and should permit a 168 MHz time-base. Refer to the clock tree diagram in the reference manual.

Two ways to measure frequency, one is to measure a high frequency count across the period/duty of the slower input. The speed here is limited to the saturation point of the processor to handle the interrupts, and compute the tick delta between one measurement and the next. The other is to count input pulses over a defined period, perhaps slaving off another counter and clocking via the external input, and then extrapolate to cycles per second.

You might also want to pick a system frequency other than 168 MHz, as the granularity/quantum is not a nice round number.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
imanpakii
Associate III
Posted on September 21, 2012 at 18:13

Thank You Clive1

I change my Clock to timer1 and right now i'm in 168Mhz clock 

but something steel wrong.when i measure pulse with 26.7 us width, the counter count it 4443 and it's doesn't make sense. Is Stm32's PLL have fix clock or it's maybe have variation?

In this case seems clock changes to 166.4 Mhz ?

Thank you for your useful comments 

imanpakii
Associate III
Posted on September 22, 2012 at 21:20

Thank You Clive1

I change my Clock to timer1 and right now i'm in 168Mhz clock 

but something steel wrong.when i measure pulse with 26.7 us width, the counter count it 4443 and it's doesn't make sense. Is Stm32's PLL have fix clock or it's maybe have variation?

In this case seems clock changes to 166.4 Mhz ?

Thank you for your useful comments 

Posted on September 25, 2012 at 03:23

I believe the PLL uses a VCO, you could measure the signal via the MCO pins. I can't say I've spent much time looking at the signal, but other clocks I've derived from it don't appear to have jitter. The accuracy of the clock will depend on the source it's being compared too. You might want to confirm the VCAPx pins, and that you have suitable capacitance there, and adequate bulk and decoupling capacitors on the supplies.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
imanpakii
Associate III
Posted on September 26, 2012 at 18:39

Hi CLive1

Thank you for your time and your replies.

After i work on my project i found out the problem did not for clock accuracy. It's for edge sharpness my signal that i trying to capture it has not good edge and the timer and clock is pretty accurate. 

thank you for your helpful and useful replies