This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Using the SDK9.01 ECAP PWM Loopback example and adding a second ECAP module so there is ECAP0 and ECAP1.
I can't seem to get SWSYNC to work, maybe I am doing something wrong...?
I run App_ecapInit() function for both ECAP0 and ECAP1.
Afterwards, the ECCTL register (offset 0x28) for both instances is 0x00360144 after initialization.
Then in the main() loop, after the above ecap initialization, I try to initiate a SWSYNC so both ECAP modules share the same count.
To SYNC:
HW_WR_REG8(gEcapBaseAddr + 0x2B, 0x01);
This writes 0x01 to the upper 8-bits of ECCTL, which sets SWSYNC = 1 (this is bit 24 in the ECCTL register)
Is that enough to engage the SYNC, or is something else needed?
Hello Keito Katafuchi,
I am looking at your queries, and you may expect delayed replies as tomorrow is a holiday in India TI.
Regards,
S.Anil.
Hello Keito Katafuchi,
I am trying to understand what you are expecting in synch mode ?
What is your requirement in synch mode?
Regards,
S.Anil.
Hi Anil,
Consider the application where there are two waveforms.
These waveforms are synchronous, but their individual edges are out of phase and have different duty cycles.
The ECAP modules are setup for continuous count-up (not differential) and Rising/Falling/Rising/Falling for one module, the opposite for the other.
The CEVT4 and OVERFLOW events trigger reads of the registers.
I want to synchronize the ECAP timebase ONCE (initialize to ZERO (TBPHS = 0) once after they start running).
This way I can calculate the exact point in time each edge was, and compare it to later edges, etc...
However, for some reason even though I can confirm the modules are setup to enable sync events and synco is active (forgot the actual bit field names), when I write the SWSYNC bit I don't see the timebases aligning.
I am confirming alignment by sending a shared GPIO signal to them to trigger Capture Events.
I expect the same signal would trigger both module's Capture Events at the same time, and I should get the same timestamp (albeit small differences due to the skew of an input buffer and the propagation delay through the different modules)
Bonus: Since they share the same reference clock, they count up at the same time.
So comparing shared GPIO capture I can calculate an offset. Technically, if I subtract that offset I can "align" the count value (fake sync).
If all I need to do is set the SYNC enable and SYNCO, and then pass SWSYNC to an "upstream" ECAP module...maybe I should write a value to TBPHS which would really tell if they are syncronizing or not?
Hello Keito Katafuchi,
As far as I know, the synch pulses are mostly used in PWM mode and not in CAP mode.
I can check TRM and will come back. So, your requirement is that both ECAP modules start the timer at the same time.
Regards,
S. Anil.
Hi Anil, I appreciate you checking. Let me know what you confirm.
>> So, your requirement is that both ECAP modules start the timer at the same time.
They don't necessarily have to "start" at the same time, as long as a sync pulse can be used to trigger the same count to be loaded, at the same time.
I understand the sync pulse should cause the ECAP modules to load the counter with the PHS value, which if = 0x0, means on a sync event both counters should reset back to "0" and increment at the same time, as they both share the same input clock.
Hello Keito Katafuchi,
Please look at the image below.
And, your use case is that you need to feed two signals to two ECAP modules.
Now, once the interrupt is generated for the first and second ECAP modules. You can reset the TSCNT from synch pulse.
This synch pulse can be given from Software synch or EPWM5 SYNCH output value.
To pass the same as the 1st ECAP module of synch output to ECAP 2nd ECAP module by controlling ECAP_ECCTL2[6:7] SYNCOSEL register bits.
FYI, this TSCNT will reset once completion of load events only.
Regards,
Anil.