2009-10-30 06:29 AM
Timer 3 prescaler does nothing
2011-05-17 04:28 AM
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, Rob2011-05-17 04:28 AM
Probably related:
[ This message was edited by: prx on 29-10-2009 19:26 ]2011-05-17 04:28 AM
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 ]2011-05-17 04:28 AM
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.2011-05-17 04:28 AM
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 ]2011-05-17 04:28 AM
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.2011-05-17 04:28 AM
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.
2014-05-28 11:20 PM
2014-05-29 12:04 AM
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