2017-06-02 10:36 AM
The original post was too long to process during our migration. Please click on the attachment to read the original post.
Solved! Go to Solution.
2017-06-05 05:36 PM
It was quite a challenge to follow you. I've read the Notes and Apologies, but still - the waveform depicts the 'event' on channel W, the narrative talks about channel V and the log contained the problem in channel U... It would be hard to make it more confusing, even if you'd try... :)
if anyone knows of a section in the reference manual that I may have overlooked that explains why this extra step is necessary
This one:
Note: In PWM mode, the OCREF level changes only when the result of the comparison
changes or when the output compare mode switches from “frozen� mode to “PWM�mode.Forced Active changes OC_REF to 1, and then mode is changed to PWM, and as the timer is stopped, the output of comparator does not change. And there was no 'frozen' mode (which I assume is mode 000 - the RMs are far from being crystal clear) in between, so the PWM is not taken into account until the next match of counter to the respective CCR.
A brutal gotcha, this one is. And don't ask me about ST's design decisions.
JW
2017-06-05 07:41 AM
Updated Workaround:
Take the pair that is becoming the High-Side (in the example above, BLDC_V) and set its high-side to Forced Inactive for a short duration before configuring it for PWM Mode. Steps:
This works for me for now, but I'm curious if anyone knows of a section in the reference manual that I may have overlooked that explains why this extra step is necessary.
2017-06-05 05:36 PM
It was quite a challenge to follow you. I've read the Notes and Apologies, but still - the waveform depicts the 'event' on channel W, the narrative talks about channel V and the log contained the problem in channel U... It would be hard to make it more confusing, even if you'd try... :)
if anyone knows of a section in the reference manual that I may have overlooked that explains why this extra step is necessary
This one:
Note: In PWM mode, the OCREF level changes only when the result of the comparison
changes or when the output compare mode switches from “frozen� mode to “PWM�mode.Forced Active changes OC_REF to 1, and then mode is changed to PWM, and as the timer is stopped, the output of comparator does not change. And there was no 'frozen' mode (which I assume is mode 000 - the RMs are far from being crystal clear) in between, so the PWM is not taken into account until the next match of counter to the respective CCR.
A brutal gotcha, this one is. And don't ask me about ST's design decisions.
JW
2017-06-06 09:37 AM
Sorry, looking back I can definitely see that.
:(
Thanks for finding the note I'd missed and I would not have been offended if you'd basically replied with 'I wanna help, but fix your description first.'RM with the note you mentioned actually names 000 as 'Frozen'. So it seems that currently I'm indirectly setting OCREF to 0 so I haven't actually solved the problem I've just hidden it so that the first cycle of PWM Mode 1 is 0 only because it hasn't been recalculated. Might be best to do something similar but go through 'Frozen' instead so that I PWM Mode 1 will be re-calculated on the mode change, right?How does 'Frozen' affect the outputs? The RM says that the comparison of CNT CCR has no effect on the outputs but doesn't say what does affect the outputs; does that mean they're GPIO controlled or that they stay at whatever they were set at...? Sorry, looking around I just find a bunch of ST Presentation PDFs that list 'frozen' in the OCM table without further description.
As a side-note: There's no way to see OCREF is there? I'd been looking for a way to see it as it would have helped me further debug the issue and probably would've led me to the solution without having to post here.
Eitherway, thanks again. :)
2017-06-06 09:57 AM
How does 'Frozen' affect the outputs? The RM says that the comparison of CNT CCR has no effect on the outputs but doesn't say what does affect the outputs; does that mean they're GPIO controlled or that they stay at whatever they were set at...?
I'd say the latter. Frozen should not influence OCxREF, and the outputs should not change their state if OCxREF does not change (unless other control bits and signals are wiggled of course).
As a side-note: There's no way to see OCREF is there? I'd been looking for a way to see it as it would have helped me further debug the issue and probably would've led me to the solution without having to post here.
I know of no direct way except through its 'native' outputs (but they are both in use in your application).
I'd try to visualize one OCxREF by setting it as TRGO (of course only one of the four OCxREF can be treated in this way), and then set another timer to accept that TRGO as its TRGI and set it to Gated mode and a high-frequency PWM output to a pin. There may be some better way I don't know of.
You may try to use the fourth unused channel, modify the software so that it undergoes the same mode changes than one of the used channels, and to output its OC4REF as directly as possible onto its respective pin.
JW