BBAI-64 PRU_ICCSG0 ECAP_APWM mode

Does anyone have an example of how to use the PRU_ICSSG0_PR1_ICSS_ECAP0_ECAP_SLV at 0x0b030000 in the APWM mode. The technical manuals say this is available at P8_15, Ball A29, MODE 4. I have added a overlay referred to as “MotorControl.dts” with a section that I used SysConfig as follows.

&main_pmx0 {
mypru_icssg0_ecap1_pins_default: mypru_icssg0_ecap1_pins_default {
pinctrl-single,pins = <
J721E_IOPAD(0xf8, PIN_INPUT, 4) /* (AB29) PRG0_PRU0_GPO18.PRG0_ECAP0_IN_APWM_OUT */
>;
};
};

The code I am using which I have successfully run on a SK-AM64B where I used the “pru-software-support-package/am64x/pru_ecap,h” file.

#define PRU_ECAP_LOC 0x0b030000 // Address from sprul1c,pdf page 136
volatile far ecap *CT_ECAP_PTR = (volatile ecap *)(PRU_ECAP_LOC);

CT_ECAP_PTR->CAP1 = 10000; // 20 Khz
CT_ECAP_PTR->CAP2 = 5000; //  Duty Cycle
CT_ECAP_PTR->CNTPHS = 0;

/* Enable APWM mode and enable asynchronous operation; set polarity to active high */

// CT_ECAP_PTR->ECCTL2_ECCTL1 = 0x02C00000;
CT_ECAP_PTR->ECCTL2_ECCTL1 = 0; // Clear ECCTL2 and ECCTL1
CT_ECAP_PTR->ECCTL2_ECCTL1_bit.CAP_APWM = 1; // ECAP operates in APWM mode
CT_ECAP_PTR->ECCTL2_ECCTL1_bit.APWMPOL = 0; // Active high
CT_ECAP_PTR->ECCTL2_ECCTL1_bit.SYNCO_SEL = 3; // Disable sync out
CT_ECAP_PTR->ECCTL2_ECCTL1_bit.TSCNTSTP = 1; // Start counter ECAP PWM Free running

// CT_ECAP_PTR->ECCTL2_ECCTL1|= 0x00100000;

Added 2 statements to code shown in previous post:
/* Enable peripheral mode, FAST IO disabled __r30 outputs /
CT_CFG.gpcfg0_reg_bit.pr1_pru0_gp_mux_sel = 1;
/
Enable ECAP clock */
CT_CFG.cgr_reg_bit.ecap_clk_en = 1;

Modified /opt/source/dtb-5.10-ti/src/arm64/overlays/robotics-cape.dts and saved as MotorControl.dts
// SPDX-License-Identifier: GPL-2.0
/*

/dts-v1/;
/plugin/;

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/pinctrl/k3.h>
#include <dt-bindings/board/k3-j721e-bone-pins.h>
#include <dt-bindings/soc/ti,sci_pm_domain.h>
#include <dt-bindings/input/linux-event-codes.h>
&{/chosen} {
overlays {
MotorControl.kernel = TIMESTAMP;
};
};

&cape_header {
pinctrl-names = “default”;
pinctrl-0 = <
&P8_07_gpio_pin /* GPIO_bit15 /
&P8_12_pruout_pin /
Direction bit PRU0 /
&P8_15_pruout_pin /
APWM mode /
&P8_16_gpio_pin /
GPIO0_bit62 Scope debug pin /
&P8_33_qep_pin /
QEP2_B - EQEP1_B /
&P8_35_qep_pin /
QEP2_A - EQEP1_A /
&P8_14_pruout_pin /
Scope debug pin PRU1 */
>;
};