2011-01-06 02:26 AM
2011-05-17 05:20 AM
PWM comes from a timer. I just looked at the general purpose timers. But other timers may work as well. Assuming you are not using all the capture / compare registers set a free one to generate an ADC trigger at the right time. It’s not strictly phase delay but it just might work.
2011-05-17 05:20 AM
Hi,
Thanks for your reply.So, if I did understood, I should setup the PWM on one CC channel and use another CC channel to trig the ADC conversions in injected mode with the compare value that correspond to the delay.
But what if I want to setup the PWM in center-aligned mode?
I initially intended to route several Timers to generate a phase delay and time base.
Let me know if I'm good on this point. I would be very greatful if you had any sources to provide.Alex
2011-05-17 05:20 AM
No sources except to say learn the processor and think.
You have a timer that generates pulses. You want to trigger ADC conversion events synchronized to your pulse generation. If a CC on the timer is available to make trigger generation easier use it. If not, use another timer and keep them running together. Or use external hardware to pull a line that triggers ADC conversion. Life gets tricky if you need to vary the PWM frequency. On the subject of Software Design Specifications: don’t make the mistake of specifying something that can’t be implemented. Mr. PICguy recommends actually implementing the hard parts to prove that they can, in fact, be done. And that you can do it. If you hired me I would start by understanding what you are trying to accomplish with a Cortex processor. Big picture first. Then all of those parts that involve sensing or controlling external hardware have to fit into the big picture. Do you have enough timers, ADC inputs, GPIO, PWM and whatever to do the big picture. Power budget. Processor clock budget. Cost budget. That kind of stuff. I am a bottom up software guy. I do critical low-level code first. If the low-level command and control can’t work then the product can’t work. It’s better to know that sooner rather than later. This the wrong place to recount horror stories of software failure brought on by design decision failure. Parting platitude: Quality is not about adherence to design documents or specs. Quality is your products’ perception in the mind of the customer.2011-05-17 05:20 AM
As PICguy said, it is important to know what you want to accomplish.
The timers of the STM32 are very versatile. You can also connect two timers in a master-slave configuration. But you will always have delays. I just made a project where I had to measure the power output of my pwm. So I just scanned two complete pwm phases with adc using dma. At the end I calculate the average of the read values. By that I get the actual current consumption and not just some peaks or lows.