AM261x MCU+ SDK: EPWM Digital counter compare capture

| AM261x MCU+ SDK 26.00.00 |

EPWM Digital counter compare capture

# Introduction:

The EPWM Edge Detection in DCCAP is a feature to monitor the trip input to be present in a given window. A typical usecase would when the EPWMs are used for controlling a motor, then the expected high current pushes in the initial switching time is expected and if they are not present, then, there is some issue with system and the EPWMs need to to be tripped.

Flow Chart

# Example Description

This example showcases the configurations needed to use the Edge Detection feature in the DCCAP to detect occurrence of a trip event in a configured time window. The window is configured by MIN and MAX values configured in MINMAX register set. Purpose of this window is to detect the occurrence of such edge. If no such edge occurs, this module will generate a trip event as well as interrupt configurable by user.

EPMW0_A (EPWM2_A in case of AM261x-LP) to detect the trip within a MINMAX window and trip its EPWMxA output EPMW1_A waveform is used as a trip input.

# Configurations

1. EPWM0 (EPWM2 in case of AM261x-LP)
   - DCCAP is enabled, trip inputs are configured for Trip1.
   - waveform A/B are configured (in the example) to match the min-max window for observing.
   - IN Trip zone, CAPEVT is configured for CBC source and Trip action on output A to low Action when trip occured.
   - XCMP is enbaled for this feature usage.
2. EPWM1
   - XCMP is enabled (not a necessary requirement)
   - generates a waveform, that goes high on counter = 100, goes low on counter = 1000, for a period of 2000
3. PWMXbar 0 to take GPIO45 via Inputxbar (a common pin that has EPWM 1A output)

Note
  The EPWM1A is routed internally via GPIO. if wish to use a different/external trip input, then,
  1. remove EPWM 1A configuration (either pinmux or all configurations from syscfg)
  2. Add GPIO45 as a input pin.
  3. connect external trip input to GPIO45

# External Connections

EPWM0_A/B (EPWM2_A/B in case of AM261x-LP) and EPWM1_A pin can be connected to an oscilloscope to view the waveform.

## AM263Px-CC or AM261x-SOM

When using AM263Px-CC or AM261x-SOM with MDSHSECDOCK (HSEC180 controlCARD Baseboard Docking Station)

- EPWM0A can be observed on HSEC PIN 49
- EPWM0B can be observed on HSEC PIN 51
- EPWM1A (Trip Input) can be observed on HSEC PIN 53.

## AM263Px-LP

Probe the following on boosterpack

- EPWM0A can be observed on J2/J4 pin 11
- EPWM0B can be observed on J6/J8 pin 59
- EPWM1A (Trip Input) can be observed on J2/J4 pin 37

## AM261x-LP

Probe the following on boosterpack

- EPWM2A can be observed on J2/J4 pin 40
- EPWM2B can be observed on J2/J4 pin 39
- EPWM1A (Trip Input) can be observed on J5/J7 pin 69

# Supported Combinations

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

# 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)
- Establish connections as mentioned in External Connections section
- 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 Capture Logic Test Started ...
minValue : 10 maxValue : 60
INPUT_WAVEFORM_RISING_EDGE_COUNTER_VALUE : 100
CAPEVT Status = 1
DCCAP Status = 1
minValue : 10 maxValue : 160
INPUT_WAVEFORM_RISING_EDGE_COUNTER_VALUE : 100
CAPEVT Status = 0
DCCAP Status = 1
minValue : 60 maxValue : 110
INPUT_WAVEFORM_RISING_EDGE_COUNTER_VALUE : 100
CAPEVT Status = 0
DCCAP Status = 1
minValue : 60 maxValue : 210
INPUT_WAVEFORM_RISING_EDGE_COUNTER_VALUE : 100
CAPEVT Status = 0
DCCAP Status = 1
minValue : 110 maxValue : 160
INPUT_WAVEFORM_RISING_EDGE_COUNTER_VALUE : 100
CAPEVT Status = 1
DCCAP Status = 1
minValue : 160 maxValue : 210
INPUT_WAVEFORM_RISING_EDGE_COUNTER_VALUE : 100
CAPEVT Status = 1
DCCAP Status = 1
EPWM Capture Logic Test Passed!!
All tests have passed!!

EPWM DCCAP Edge Monitoring Sample output

when edge is before minimum value of the window

when edge is after the maximum value of the window

when edge is in the minimum and maximum value range of the window