2020-04-17 11:46 AM
Hi,
I am synchronizing two timers, actually already succeed but I was stuck two days because the trigger output event TRGO of TIM1 was connected to OC4REF (and CCR4 was accordingly set).
With this configuration I didn't receive a pulse in the slave trigger input, but when I select TRGO = OC1 and I set my value in CCR1 it worked.
I also tried with OC1REF, OC2REF and on.
My question is, what is the difference between TRGO in compare pulse (OC1) and in OCxREF?
I am using STM32G474RE
Thanks!!
Daniel
Solved! Go to Solution.
2020-04-18 11:08 AM
The difference between compare pulse (MMS==0b0011) and compare tim_oc*refc (0b0100 <= MMS <= 0b0111) is that
So I think that setting the channel to PWM mode 2 would solve your problem if the red remark at the bottom means that the slave is indeed triggered, but at CNT==0 instead of CNT==CCR
2020-04-17 03:44 PM
Which two of these are you talking about?
They should work the same (except the different channel number). Read out and post content of both timers' registers in the "non-working" setting.
JW
2020-04-18 12:22 AM
Hi JW,
thanks for your response.
That's what I taught, that they should work the same way.... but for some reason OC1 and OC1REF are named differently. What is the difference between them?
I taught that maybe is the way the CCP1 is initialized?
If I use OC4REF and configure CCP4 to have a '1' in TRGO and if I use OC1REF and configure CCP1 it should be the same? And what if instead of OC1REF I use OC1?
By not-working I mean that the outputs of the slave timer are not synchronized.
Maybe is the way I should configure in the STM32CubeIDE in the picture?
Thanks!
Daniel
2020-04-18 02:20 AM
CubeMX settings mean nothing. Please post the contents of the timer registers.
2020-04-18 03:29 AM
Hi Berendi,
Attached are two screenshots. At the left, TRGO is configured as OC1 and at the right OC1REFC. Just noted it ends in C, maybe is the complementary?
Anyways, it is strange that it doesn't act the same.
You can see also at the left and right that CCR1 is 333. In the left one (works ok) the trigger is at this value. In the right one, I see in the oscilloscope that the trigger is like CCR1 is 0, but is not.
2020-04-18 04:26 AM
I don't know what the Cube/CubeMX folks mean by OC1. They keep inventing their own terminology, not matching the RM, so if you want to know what that does, you have no other option than generate the code and then go and reverse engineer the stuff to get to the bottom. I am not interested in that game so I simply don't use Cube/CubeMX at all.
JW
2020-04-18 04:46 AM
Okay so in the first case, MMS=0b011 Compare Pulse, when compare happens, TRGO outputs a pulse lasting one timer clock.
In the latter, MMS=0b100 so it's OC1REFC (I used an older version of RM0440 for the screenshot above, missing the "c" incorrectly). The C in OC1REFC comes from the fact that it's not OC1REF directly, but it's the result of combination with OC2REF, see description of combined/asymmetric modes in the description of OC1M in TIMx_CCMR1
As you don't have set any of the combined modes, in your case, the TRGO is then the same shape as the output you see on the pin, ie. "normal" PWM1 waveform.
Now why this does not do what you expect in triggering the slave, might depend on the particular setting of the slave, and in the particular sequencing of events.
JW
2020-04-18 05:14 AM
Thanks JW,
I understand now more about the output triggers.
I read the reference manual and try to select OC4REF and play with to OC4M register to check if I can use OC4REF as TRGo but with no success.
My project works, only that I used OC1 instead. I would like to know how to use OCxREF for future cases if its possible.
But really thanks for the help JW!!
2020-04-18 11:08 AM
The difference between compare pulse (MMS==0b0011) and compare tim_oc*refc (0b0100 <= MMS <= 0b0111) is that
So I think that setting the channel to PWM mode 2 would solve your problem if the red remark at the bottom means that the slave is indeed triggered, but at CNT==0 instead of CNT==CCR
2020-04-18 12:54 PM
Once again, read out and post both the master and slave timers registers, for the non-working case.
JW