AM5728 eHRPWM Driver and Interrupt Design Notes
eHRPWM Waveform Generation Method
(1) Copy the pwm1.sh script to the /opt/tools directory.
(2) Run the following commands:
root@am57xx-evm:/opt/tools# chmod 777 pwm1.sh
root@am57xx-evm:/opt/tools# ./pwm1.sh 1000000 500000 200000
Set APWM1 mode successfully!
root@am57xx-evm:/opt/tools# cat /sys/kernel/debug/pwm
platform/dmtimer-pwm@16, 1 PWM device
pwm-0 (pwm_fan ): requested enabled
platform/48440200.pwm, 2 PWM devices
pwm-0 (sysfs ): requested enabled
pwm-1 (sysfs ): requested enabled
platform/4843e100.ecap, 1 PWM device
pwm-0 (backlight ): requested enabled
root@am57xx-evm:/opt/tools# cat /sys/class/pwm/pwmchip1/pwm0/{enable,period,duty_cycle}
1
1000000
500000
root@am57xx-evm:/opt/tools# cat /sys/class/pwm/pwmchip1/pwm1/{enable,period,duty_cycle}
1
1000000
200000
(3) Then measure the EHRPWM2B pin using an oscilloscope.

(4)./pwm1.sh 1000000 500000 200000 (Duty cycle can be adjusted)
(5) Restart to change the period../pwm1.sh 2********000000 500000 200000
This debugging is based on the Xinming Technology XM5728-IDK-V3 development board.

AM5728: Beagle-x15 board the output for EHRPWM2A pins issue
C6747 EHRPWM Example
https://processors.wiki.ti.com/index.php/C6747_EHRPWM_Example
Linux/AM6548: ehrpwm
https://e2e.ti.com/support/processors/f/791/t/748195
TI WIKI:
Regarding CTRL_MMR0 tbclk, you need to enable this in the driver file (pwm-tiehrpwm.c), using register CTRLMMR_EPWM0_CTRL/0x00104140.
See for example how the CTRLMMR_OLDI_DAT0_IO_CTRL/0x001041E0 register is used in the following files:
linux-4.14.67/drivers/gpu/drm/tidss/tidss_dispc7.h
linux-4.14.67/drivers/gpu/drm/tidss/tidss_dispc7.c
Regards,
Pavel
~/XM/kernel/Linux/drivers$ vi pwm/pwm-tiehrpwm.c

https://git.ti.com/cgit/apps/tida01555/tree?h=master

Page 6931
~/XM/kernel/Linux/drivers$ vi irqchip/irq-crossbar.c
Are these codes useful?
C:\ti\processor_sdk_rtos_am57xx_6_03_00_106\pdk_am57xx_1_0_17\packages\ti\csl\example\gpio\gpio_interrupt.c
C:\ti\processor_sdk_rtos_am57xx_6_03_00_106\pdk_am57xx_1_0_17\packages\ti\csl\arch\a15\src\ interrupt.c
C:\ti\processor_sdk_rtos_am57xx_6_03_00_106\pdk_am57xx_1_0_17\packages\ti\csl\arch\c66x\ interrupt.c
Please refer to ~/pdk_am57xx_1_0_17/packages/ti/osal/src/tirtos/RegisterIntr_tirtos.c for the OSAL APIs you can use to install ISR in TI-RTOS.
You can also refer to ~/pdk_am57xx_1_0_17/packages/ti/drv/uart/src/v1/UART_v1.c as an example of how the APIs are used.
https://e2e.ti.com/support/processors/f/791/t/931094?CCS-AM5728-EHRPWM-Interrupt-in-DSP-with-TI-RTOS
In AM5728's DSP processor, we need EHRPWM Interrupt with TI RTOS. The question is how to register the interrupt ISR?
We need to detect the phase using ehrpwm2A or ehrpwm2B interrupts when the counter decreases from period to zero.
I have configured the registers for interrupt as follows:
void PWM_InterruptConfig(void)
{
/*
* AM57x DSP does not have a default Xbar connection for PWM
* interrupts; a reserved IRQ Xbar instance must be used for Xbar
* interrupt configuration
*/
/* Use reserved XBAR_INST_DSP1_IRQ_34 */
CSL_xbarIrqConfigure(CSL_XBAR_IRQ_CPU_ID_DSP1, CSL_XBAR_INST_DSP1_IRQ_34, CSL_XBAR_PWMSS2_IRQ_ePWM1INT);
// Disable the ePWM Event interrupt.
CSL_epwmEtIntrDisable(PWM_BASE_ADDRESS);
// Configure the interrupt source and interrupt period.
// Enable event time-base counter equal to zero.
// Generate an interrupt on the first event.
CSL_epwmEtIntrCfg(PWM_BASE_ADDRESS, PWMSS_EPWM_ETSEL_INTSEL_CTR_0, PWMSS_EPWM_ETPS_INTPRD_GEN_FIRST_EVT);
// Enable the ePWM Event interrupt.
CSL_epwmEtIntrEnable(PWM_BASE_ADDRESS);
}

But I also need to write an ISR, which must be registered or installed.
How to register it in TI RTOS?
Are these codes useful?
C:\ti\processor_sdk_rtos_am57xx_6_03_00_106\pdk_am57xx_1_0_17\packages\ti\csl\example\gpio\gpio_interrupt.c
C:\ti\processor_sdk_rtos_am57xx_6_03_00_106\pdk_am57xx_1_0_17\packages\ti\csl\arch\a15\src\ interrupt.c
C:\ti\processor_sdk_rtos_am57xx_6_03_00_106\pdk_am57xx_1_0_17\packages\ti\csl\arch\c66x\ interrupt.c
Thanks,
How to specify pinmux configuration for EHRPWM0 in motor_control example for IDK AM437x?
How to get AM335x ePWM interrupt
https://e2e.ti.com/support/legacy_forums/embedded/linux/f/354/p/474058/1705662
request_irq failed**/GPIO Example******
https://e2e.ti.com/support/processors/f/791/t/395791
Dts:
~/XM/kernel/Linux/arch/arm/boot/dts$ vi dra7.dtsi
~/XM/kernel/Linux/arch/arm/boot/dts$ vi am57xx-evm-common.dtsi


