cancel
Showing results for 
Search instead for 
Did you mean: 

Timer 3 prescaler does nothing

robertwood9
Associate III
Posted on October 30, 2009 at 14:29

Timer 3 prescaler does nothing

10 REPLIES 10
robertwood9
Associate III
Posted on May 17, 2011 at 13:28

Folks,

I have timer three running as a PWM and I would expect if I changed the PSC register (TIM3_PSC) it would affect the frequency of the PWM. So, if I increased the value of the prescaler, it would reduce the frequency because the clock is divided by PSC+1 before incrementing the counter (TIM3_CNT) by one.

However, it makes not one iota of difference to the frequency of the PWM. The only thing that makes any difference to the PWM is TIM3_ARR (which does make sense).

Do I misunderstand what the prescaler does?

Many thanks,

Rob

akaiser9
Associate II
Posted on May 17, 2011 at 13:28

Probably related:

http://www.st.com/mcu/forums-cat-8739-23.html

[ This message was edited by: prx on 29-10-2009 19:26 ]

robertwood9
Associate III
Posted on May 17, 2011 at 13:28

Thanks for the reply, prx. I must confess I don't understand the point you are making. I assumed you were saying you have to set the prescaler before ARR, but that makes no difference.

I then looked at your code and you were setting PSC before ARR which is what I was doing.

Also, I am not using interrupts, just creating a PWM. In your code you seem to wait before you get the first timer overflow before setting the interrupt, but that's not relevant for me!

Would you mind clarifying the point you were making please?

Also, you were talking about disabling the prescaler, but as far as I can see there's no way to do that. Unless you mean you set it to zero?

Many thanks,

Rob

[ This message was edited by: robert.wood on 30-10-2009 10:55 ]

paulsmitton9
Associate III
Posted on May 17, 2011 at 13:28

Hi Rob,

I have successfully used the timer 3 prescaler (via the firmware libraries (which set TIM3->PSC to the required value). It does change the counter frequency (after an update: figures 73 and 74 of my manual).

Not sure if that offers any reassurance, but I'd check you've got the correct address, and perhaps test an example from the firmware libraries. I faced a similar issue on the STR9 until I realised that my prescaler value was out of range.

Paul.

robertwood9
Associate III
Posted on May 17, 2011 at 13:28

Hi Paul,

Thanks for the reply. It's not a case of the prescaler not being set, just that whatever value you set it to, the period of the PWM remains unaltered.

prx seems to be saying he found the same point (and he also uses Crossworks), so maybe there is an issue with that.

It might be that you have to set the registers in a specific order, but the manual doesn't seem to indicate that.

I'm not using the libraries at all, they're too obfuscated for my liking!

Cheers,

Rob

[ This message was edited by: robert.wood on 30-10-2009 12:27 ]

akaiser9
Associate II
Posted on May 17, 2011 at 13:28

I've described the problem and the prescaler behavior in more details in the other thread. See there.

Concerning your case: If you write to PSC, the modified value does not affect the prescaler until the counter hit ARR at least once. So when you write to PSC, the current PWM cycle is not affected by the change, but the next cycle should be.

robertwood9
Associate III
Posted on May 17, 2011 at 13:28

OK, for anyone else who might come across this, you have to make sure the UDIS bit is cleared. It says that the PSC, ARR etc are reinitialised if this is set, but it seems to be reinitialised with zero rather than what's in the prescaler register, Doesn't make sense to me, but then, the documentation ain't great for these processors.

arsalan
Associate
Posted on May 29, 2014 at 08:20

I have the same problem. 

My prescaler does not work.

Have you solved your problem?

Posted on May 29, 2014 at 09:04

Start a new thread, posting a minimal but complete compilable code exhibiting the problem, explaining the symptoms and how do they fall short of your expectations.

JW