Configuring an STM32F3xxx timer to drive half-bridge SMPS - Page 1
Forum section: electronics / general

author: fourtytwo42
author_rank: Super Contributor
timestamp: May 06, 2018, 12:18:34 pm
content: Hello everyone, I am having trouble figuring out how to configure any timer in the STM32F3xxxx to drive a half bridge SMPS. It seems it is able to produce "complimentary" outputs where one is the inverse of the other but that is not what I need.What I am looking for is at say 25% duty cycle output A is on for 25% whilst B is off, then B is on for 25% whilst A is off.Am I going blind, I have read the REF manual again and again and tried AN4776 (timer cookbook) all to no avail.Has anybody out there done this before and be willing to give me a clue/s please

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 06, 2018, 04:54:49 pm
content: Isn't what you need complementary outputs with programmable dead-time?The advanced timer TIM1 can be used as "complementary PWM outputs with programmable inserted dead-times".The datasheets themselves only describe functionalities, but to get more details, download the reference manual and look for "Complementary outputs and dead-time insertion".

author: newbrain
author_rank: Super Contributor
timestamp: May 06, 2018, 05:03:36 pm
content: Ninjaed by a wizard...I'll just provide thelink to the ref manual, and the relevant chapters: 20.3.15, and 20.4.18.

author: fourtytwo42
author_rank: Super Contributor
timestamp: May 06, 2018, 06:06:21 pm
content: Thank you for your repliesAs I said I have already read the referance manual from cover to cover BUTComplimentary mode with deadtime doesnt do it as that only covers the case of 100% duty cycle with deadtime.Yes it could drive something like a CCFL inverter where the duty cycle is always near 100% but not a variable power smps where the duty cycle may vary from maybe 1-99%. Another way to consider a half-bridge is the two drive signals need to look like a push-pull circuit using a centre tapped transformer and two switches that are on on alternate pwm cycles for a variable (but importantly identical) duty cycle.Unfortunatly the complimentary mode takes the singular OCyREF internal pwm output and applies it to the true and compliment outputs with deadtime insertion but otherwise simeltaniously, not alternatly.I hope I am making sense.I am seriously worried this thing cannot hack it and if thats the case I would be suitably astonished, so I am hoping I have just missed something somewhere

author: newbrain
author_rank: Super Contributor
timestamp: May 06, 2018, 06:38:09 pm
content: You might be looking for this, then:20.3.13 Combined PWM modeQuoteI've never used this mode so I cannot provide much guidance...But is it something like this what you're trying to achieve?Code:________| |___________________________| |______

author: fourtytwo42
author_rank: Super Contributor
timestamp: May 06, 2018, 06:53:48 pm
content: I did look at that, in particular figure 177 but sadly all the output signals are identical in the two pwm cycles shown, i.e. there is nothing alternate about them.Yes I am trying to acheive the signals in your very good diagram but the critical factor is they must be the same width derived from a single duty cycle register.The way ST are generating a pattern like that is to use two seperate channel comparitors from the same master pwm and that simply won't work as there is no sane way to simeltaniosly adjust the duty cycle.I cannot fathom why they just didnt put a flip-flop in the output logic like Microchip, I think I am going to have to put the STM32 in the graveyard after a lot of time invested and look for something elseP.S. Thank you very much for your help

author: newbrain
author_rank: Super Contributor
timestamp: May 06, 2018, 07:02:51 pm
content: It's possible to have the CCRx registers loaded in the actual comparator register only at update events, rather than at write time.Could this ease the synchronisation?Quote

author: fourtytwo42
author_rank: Super Contributor
timestamp: May 06, 2018, 07:11:17 pm
content: I think it would were I not doing other things such as using an analogue comparitor input to determine the actual termination of the output pulse irrespective of the duty cycle setting so I am afraid that means it will only work if the pwm is post processed in a flip-flop manner rather than the way ST do it. Sadly my initial evaluation only consisted of checking there were at least two outputs per pwm and that analogue comparitors were able to terminate the pwm in an auto-restart next cycle manner. All those things it does but I did not expect the two outputs to be unable to operate in push-pull/half-bridge mode so I guess I got caught with my pants down

author: newbrain
author_rank: Super Contributor
timestamp: May 06, 2018, 07:20:50 pm
content: Ah, Ok...Getting more and more complicated. Are you using the break function with input from the comparator?Having never used an F3, and this timer functions, I don't think I can help you much

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 06, 2018, 07:26:27 pm
content: What's your target PWM frequency? If it's low enough, you could handle the IO's yourself in simple timer interrupts, without an excessive penalty.

author: fourtytwo42
author_rank: Super Contributor
timestamp: May 06, 2018, 07:30:43 pm
content: Yes I am/would be using the break function, but now ........Yup the F3 had the right mix of analogue and digital for me, similar to the PIC24EVxxxMCxxx series that I was using.Reason for change, bogged down in Errata/workarounds and undocumented bugs in the PIC PWM BUT at least driving a half bridge it can do with eyes shut hahahaAnyway just so everybody knows, the STM32F3 cannot drive half-bridge or push-pull smps's!! Not much of a PWM

author: fourtytwo42
author_rank: Super Contributor
timestamp: May 06, 2018, 07:35:52 pm
content: Quote from: SiliconWizard on May 06, 2018, 07:26:27 pmOnly 25Khz (but a later target of 125Khz) but having experienced the instruction set and actual vs claimed execution rate I wouldn't like to try it and there is a lot of complexity beyond a simple PWMBig MOSFETS are expensive as is replaceing burnt pcb'sI think I am making excuses here, it might be worth thinking about but it would be hard to keep the interrupt latencies low enough as there are lots of other realtime control functions going on and thats where the MIPS were supposed to be used.

author: halil82ist
author_rank: Newbie
timestamp: March 26, 2020, 05:01:43 pm
content: Hi . My precious friend. I'm having the same problem. have you found a solution? Thank you. sorry for my english

author: fourtytwo42
author_rank: Super Contributor
timestamp: March 30, 2020, 09:55:46 am
content: Hi, sorry for the late reply, no I never did find an acceptable solution so I dumped the entire chip and use PIC24EPxxxMC series for the job instead. The only other alternative would be to add a PLD external to the STM32.I evaluated many ARM based microcontrollers and they all suffer the same problem so obviously the PWM IP comes from a common source (ARM).

author: halil82ist
author_rank: Newbie
timestamp: March 30, 2020, 03:50:13 pm
content: thank you .