cancel
Showing results for 
Search instead for 
Did you mean: 

Generating center aligned PWM signal.

lipin
Associate II
Posted on September 23, 2010 at 20:00

Generating center aligned PWM signal.

7 REPLIES 7
DiBosco
Senior
Posted on May 17, 2011 at 14:08

AFAIK you can't avoid the fact you get interrupts on overflow and underflow. I've just been through all this.

As far as the waveforms go, you're best off looking with your scope to make sure they look right before powering it up. What, exactly, are you trying to drive? Why do you need to interrupt at the end of each period? Are you calculating new PWM times each cycle?

lipin
Associate II
Posted on May 17, 2011 at 14:08

Yes I am calculatig PWM time on each cycle thats the reason why I need to enter interrupt (also ramp, contol loop, current measurment, buffer voltage limiting etc.) I am using this to drive low power induction motor up to 750W. I am sure it works now but I have this unneeded overflow interrupt and calculating twice more than should. It is general question if I do it in right way and I didnt miss anything especially knowing that STM32F103RB was ment to do that job.

Regards

Thomas
DiBosco
Senior
Posted on May 17, 2011 at 14:08

The only thing I can suggest is, if you are only using three of the four compares in the timer, to set one of the compares to go off at the time you want. If that's not possible, all you can do is throw away one of the interrupts. It's poor, but ST seem to have got plenty wrong on these chips.

lipin
Associate II
Posted on May 17, 2011 at 14:08

Just checked newest RM008 its figure 72  (Update rate examples depending on mode and TIMx_RCR register settings) in there center aligned mode RCR = 1. There is small error with arrows but easy to tell its docs error by checking edge aligned mode update event generation. Thats for future reference if someone else will be intrigued by this.

Regards
lipin
Associate II
Posted on May 17, 2011 at 14:08

Thank you Robert I thought about it as alternative route of getting interrupts but setting repetition counter did the job well and I am getting only undeflow updates.

There are unnesecary tim update inidicators (arrows) in STM reference manual for repetition counter = 1 (figure 71).

Good news is simple U/f control from uc side works fine. Some problems with power part but it is going to be sorted out - fingers crossed.

Anyway if someone familiar with orginal stm32 motor control code (from STM32 Motor control kit) is able to verify if I am doing it rigth it would be great.

Regards

Thomas

PS.This forum gone totaly nuts. Not showing amount of posts in thread, not putting it on top after reply. Brrr nuts do something with it STM guys.
DiBosco
Senior
Posted on May 17, 2011 at 14:08

Hi Thomas,

You say:

''There are unnesecary tim update inidicators (arrows) in STM reference manual for repetition counter = 1 (figure 71).

Good news is simple U/f control from uc side works fine. Some problems with power part but it is going to be sorted out - fingers crossed.''

Not sure what you mean. Are you saying that you have found a way to only interrupt on either underflow or overflow? If so, what exactly did you do?

Cheers!

PS You're right about the updates. This forum is a bad as the STM32 documentation!
lipin
Associate II
Posted on May 17, 2011 at 14:08

Yes and no 🙂

When you use repetition counter timer generates update interrupts only every repetition counter overflow. So if you setup it to 1 you will catch tim1 counter underflow interrupts only. 

Look at figure: Update rate examples depending on mode and TIMx_RCR register settings. 

Arrows in there represent update interrupt (as for RCR=1 & center aligned mode you should dicard those thin arrows that is documentation error). This way you can get underflow interrupts but not ones (hmm or you can by setting RCR inside interrupt I dint try it).

I would give you a tip what helped me reading documentation. Make a quick look at overview pick some interesting register names and jump to register descriptions. All modes are explained there in much cleaner way and names are corresponding to those in peripheral library.

Regards

Thomas

PS. After I wrote this post I am starting to doubt if there is error or I just understood it wrong. I am going to post it in new message maybe we will get more attention being at the top of the post list.