Other Parts Discussed in Thread: CONTROLSUITE,
Hi,
I have the problem to get my HRPWM cycles synchronised exactly to an external clock signal (e.g. EtherCAT DC SYNC0). My idea is to capture both the external sync signal and (an extra) EPWM output or the EXTSYNCOUT generated by the EPWM sync chain with two different, but synchronously running ECAP modules, to compare the captured edges and to ajust the (high resolution) period registers of the PWMs accordingly. Using SYNCIN of the ECAPs seems not to be a good option, since this reloads the ECAP counter and gives no result when this happened.
I successfully tried to read back the EPWM on the _same_ GPIO and feed it via input XBAR to the eCAP inputs. Similar this works for EXTSYNCOUT:
EALLOW; // This is needed to write to EALLOW protected registers
/* epwm 1 ctr = 0 as sync out to gpio 2 */
EPwm1Regs.TBCTL.bit.SYNCOSEL = 1; // 1: counter = zero
SyncSocRegs.SYNCSELECT.bit.SYNCOUT = 0; // 0: EPWM1SYNCOUT
/* program output xbar */
OutputXbarRegs.OUTPUT1MUX0TO15CFG.bit.MUX14 = 3; // EXTSYNCOUT
OutputXbarRegs.OUTPUT1MUXENABLE.bit.MUX14 = 1;
// configure GPIO2 as OUTPUTXBAR1
GpioCtrlRegs.GPAGMUX1.bit.GPIO2 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1;
GpioCtrlRegs.GPAQSEL1.bit.GPIO2 = 3; // async input for read back
GpioCtrlRegs.GPADIR.bit.GPIO2 = 1; // output
/* directly read back extsyncout on gpio02 */
InputXbarRegs.INPUT7SELECT = 2; // goes to eCAP1
The code to read back an EPWM output is similar.
The controlSUITE example C:\ti\controlSUITE\device_support\F2807x\v210\F2807x_examples_Cpu1\ecap_capture_pwm\cpu01\ECap_Capture_Pwm_cpu01.c suggests another way: It recommends to use two different IO pins. However, our GPIO usage is very tight (100 pin package).
Are there any reasons that vote against my version?
Will this work with the TMS320F2837xS too?
Any better idea for the synchronisation mechanism (that doesn't need a GPIO)?
Thanks,
Frank