AM261x MCU+ SDK: EPWM Synchronization

| AM261x MCU+ SDK 26.00.00 |

EPWM Synchronization

# Introduction

This example configures 6 instances of EPWM, with EPWM0 taken as the reference and the other five EPWM instances are phase shifted with respect to it. EPWM0, EPWM1, EPWM2 and EPWM3 are configured using Sysconfig while EPWM4 and EPWM5 are configured using a function. Additionally, functions are defined that can change the phase and duty cycle of EPWMs while they are running. In this example synchronization is achieved by providing the sync-out pulse of EPWM0 as the sync-in pulse to EPWM1, EPWM2, EPWM3, EPWM4 and EPWM5. On receiving this sync-in pulse the EPWM time-base counter will start counting from the phase shift value up until period value. Further, 6 ECAP modules are integrated in capture mode to capture the waveform in order to validate the synchronization results. These ECAP modules are also synchronized wherein the sync-in pulse are provided by the sync-out pulse of EPWM0, and they are configured to detect the event of falling edge in the EPWM waveforms

The sync-in options available are:

1. EPWMx sync-out signal where x=0,1,2..23
2. ECAPx sync-out signal where x=0,1,2..9
3. Input XBAR outx signal where x=4,20
4. TimeSync xbar pwm output x signal where x=0,1
5. FSIRX0 Trigger x signal x=0,1,2,3
6. FSIRX1 Trigger x signal x=0,1,2,3
7. FSIRX2 Trigger x signal x=0,1,2,3
8. FSIRX3 Trigger x signal x=0,1,2,3

The sync-out event options available are:

1. Software force generated EPWM sync-out pulse
2. Counter zero event
3. Counter equal to CMPB event
4. Counter equal to CMPC event
5. Counter equal to CMPD event
6. DCA Event 1 Sync signal generates EPWM sync-out pulse
7. DCB Event 1 Sync signal generates EPWM sync-out pulse
8. Combination of one or more of above sources

For this example, we have configured EPWM0 sync-out signal to be the sync-in pulse for EPWM1, EPWM2, EPWM3, EPWM4, EPWM5. This sync-out pulse is generated at the counter zero event of EPWM0. Once the other modules receive this sync-in pulse, their counter will be at the phase value configured which is 300 for EPWM1, 600 for EPWM2, 900 for EPWM3, 450 for EPWM4, 750 for EPWM5. Also the six ECAP modules are synchronized with EPWM0, by configuring their sync-in source as EPWM0 sync-out signal. The phase values for all the ECAP modules are configured to be 0. In this example, the configurations for EPWM0, EPWM1, EPWM2 and EPWM3 are done through SysConfig while the configurations for EPWM4 and EPWM5 are done through the function AppEpwmInit in the C file. Further two more functions namely AppEpwmDutyCycleUpdate and AppEpwmPhaseUpdate are defined to update the duty cycle and phase of already running PWM waveforms. Here, the load from Shadow to Active registers occur when the time-base counter reaches zero. This event varies depending on the counter-mode we have set for our EPWM modules. If the counter mode is up-count/down-count then this event occurs only once. When the counter mode is up-down count then this event occurs two times.

Waveform representation of phase shifted EPWM

# Example Description

The example uses the following EPWMs to showcase the Synchronization features which includes:

1. CONFIG_EPWM0 - This EPWM module is taken as the reference with 0 degree phase shift
2. CONFIG_EPWM1 - This EPWM module is phase shifted by 300 TBCLK
3. CONFIG_EPWM2 - This EPWM module is phase shifted by 600 TBCLK
4. CONFIG_EPWM3 - This EPWM module is phase shifted by 900 TBCLK
5. CONFIG_EPWM4 - This EPWM module is phase shifted by 450 TBCLK
6. CONFIG_EPWM5 - This EPWM module is phase shifted by 750 TBCLK

1. REF_CAPTURE - This ECAP module instance is used to capture falling edge event of EPWM0_A
2. ECAP1_CAPTURE - This ECAP module instance is used to capture falling edge event of EPWM1_A
3. ECAP2_CAPTURE - This ECAP module instance is used to capture falling edge event of EPWM2_A
4. ECAP3_CAPTURE - This ECAP module instance is used to capture falling edge event of EPWM3_A
5. ECAP4_CAPTURE - This ECAP module instance is used to capture falling edge event of EPWM4_A
6. ECAP5_CAPTURE - This ECAP module instance is used to capture falling edge event of EPWM5_A

Block diagram of EPWM Synchronization

Integration of ECAP to capture EPWM waveform

# External Connections

When using AM263x-CC or AM263Px-CC with TMDSHSECDOCK (HSEC180 controlCARD Baseboard Docking Station) Probe the following on the HSEC pins

- CONFIG_EPWM0 - EPWM 0A/0B : 49 / 51
- CONFIG_EPWM1 - EPWM 1A/1B : 53 / 55
- CONFIG_EPWM2 - EPWM 2A/2B : 50 / 52
- CONFIG_EPWM3 - EPWM 3A/3B : 54 / 56
- CONFIG_EPWM4 - EPWM 4A/4B : 57 / 59
- CONFIG_EPWM5 - EPWM 5A/5B : 61 / 63

When using AM261x-SOM with TMDSHSECDOCK (HSEC180 controlCARD Baseboard Docking Station) Probe the following on the HSEC pins

- CONFIG_EPWM0 - EPWM 0A/0B : 49 / 51
- CONFIG_EPWM1 - EPWM 1A/1B : 53 / 55
- CONFIG_EPWM2 - EPWM 2A/2B : 50 / 52
- CONFIG_EPWM3 - EPWM 3A/3B : 54 / 56
- CONFIG_EPWM4 - EPWM 4A/4B : 57 / 59
- CONFIG_EPWM5 - EPWM 6A/6B : 58 / 60

Early Access: For AM263Px-CC E1, the connections is same as that of AM263x

When using AM263X-LP or AM263PX-LP

- CONFIG_EPWM0 - EPWM 0A/0B : J2.11 / J6.59
- CONFIG_EPWM1 - EPWM 1A/1B : J4.37 / J4.38
- CONFIG_EPWM2 - EPWM 2A/2B : J4.39 / J4.40
- CONFIG_EPWM3 - EPWM 3A/3B : J8.77 / J8.78
- CONFIG_EPWM4 - EPWM 9A/9B : J8.75 / J8.76
- CONFIG_EPWM5 - EPWM 13A/13B : J8.79 / J8.80

When using AM261X-LP

- CONFIG_EPWM0 - EPWM 7A/7B : J8.76 / J8.75
- CONFIG_EPWM1 - EPWM 1A/1B : J7.69 / J7.63
- CONFIG_EPWM2 - EPWM 2A/2B : J2.40 / J2.39
- CONFIG_EPWM3 - EPWM 3A/3B : J2.38 / J2.37
- CONFIG_EPWM4 - EPWM 4A/4B : J2.36 / J2.35
- CONFIG_EPWM5 - EPWM 6A/6B : J8.78 / J8.77

# Supported Combinations

Parameter | Value
--- | ---
CPU + OS | r5fss0-0 nortos
Toolchain | ti-arm-clang
Board | am261x-som, am261x-lp
Example folder | examples/drivers/epwm/epwm_synchronization

# Steps to Run the Example

- When using CCS projects to build, import the CCS project for the required combination and build it using the CCS project menu (see Using SDK with CCS Projects).
- When using makefiles to build, note the required combination and build using make command (see Using SDK with Makefiles)
- Launch a CCS debug session and run the executable, see CCS Launch, Load and Run

# See Also

EPWM

# Sample Output

Shown below is a sample output when the application is run,

EPWM Synchronization Test Started ...
EPWM Synchronization Example runs for 5 Secs
Falling Edge timestamp of Reference waveform : 1002
Falling Edge timestamp of EPWM1 : 702
Falling Edge timestamp of EPWM2 : 402
Falling Edge timestamp of EPWM3 : 102
Falling Edge timestamp of EPWM4 : 552
Falling Edge timestamp of EPWM5 : 252
Observed Phase Delay between Reference Waveform and EPWM1 Waveform : 300
Observed Phase Delay between Reference Waveform and EPWM2 Waveform : 600
Observed Phase Delay between Reference Waveform and EPWM3 Waveform : 900
Observed Phase Delay between Reference Waveform and EPWM4 Waveform : 450
Observed Phase Delay between Reference Waveform and EPWM5 Waveform : 750
EPWM Synchronization Test Passed!!
All tests have passed!!

EPWM Synchronization Output Waveform