/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / 40% Error on timer1??

Username:     
Password:     
             

Forum

# 1   2008-02-14 16:54:49 40% Error on timer1??

Boelskov
New member
Registered: 2008-02-13
Posts: 5

40% Error on timer1??

Hey

Sorry for all my newbie questions :-)

I have configured timer1, and I tried to make PWM with a periode time at 1ms.

I am running in Center-aligned mode 3, and PWM mode 2. The PWM is just outputed on the pins, so I am not using interrupt at all.

The uC is clock with 8Mhz, så the PSC_counter can count to 8000 in 1ms. When I set the PSC_counter_top TIM1_ARR to 4000, it should take exactly 1ms to count from 0 to 4000 and down to 0 again.
When I am mesuring the periode on the oscilloscope the periode time is 1,4ms?? If i change the values the error is allways 40%.
I tryde to calculate the dead time as well, and the error is also 40% her. 100uS ->140uS

Has anybody tryed this? what can be the mistake?

-Niels

Offline

 

# 2   2008-02-14 17:14:07 40% Error on timer1??

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: 40% Error on timer1??

Just some ideas:
   1. Check that you are using the external oscillator HSE  instead of the internal RC. The clock scheme is quite complex, and it takes some time to configure the different divisors/multiplexer. Take a look at the "clock tree" in the user's manual.
   2. You could find in the CircleOS source files an example of PWM use in buzzer.c (Timer3 is used to generate the sound).

Offline

 

# 3   2008-02-18 14:08:15 40% Error on timer1??

Boelskov
New member
Registered: 2008-02-13
Posts: 5

Re: 40% Error on timer1??

Hey

Thanks for the tip. The problem was the clock. I used the internal instead od the external clock.
If anybody else has this problem, try to look into the registers RCC_CFGR and RCC_CR.

Finding your way through the clock tree can also help you a lot.

-Boelskov

Offline

 

# 4   2009-03-21 16:14:59 40% Error on timer1??

andras
New member
Registered: 2009-02-17
Posts: 2

Re: 40% Error on timer1??

Boelskov :

Hey

Sorry for all my newbie questions :-)

I have configured timer1, and I tried to make PWM with a periode time at 1ms.

I am running in Center-aligned mode 3, and PWM mode 2. The PWM is just outputed on the pins, so I am not using interrupt at all.

...

-Niels

Hi Niels,

are you using the STM32 Primer2? If yes, how can you access the timer pins through the extension connector?

Thank,
Andras

Offline

 

Board footer