gemstonedevteam opened a new pull request, #20138:
URL: https://github.com/apache/nuttx/pull/20138

   > Opening as draft since this depends on #20137 will mark ready once that 
lands.
   
   ### Summary
   
     * Adds a PWM lower-half driver for the AM67 eCAP modules in APWM mode, 
where
       the module is used as a single-channel PWM generator rather than a 
capture
       unit.
     * Period is programmed in `CAP1` and the compare value in `CAP2`, with the
       counter free-running from the eCAP functional clock at 125 MHz.
     * `start()` reprograms the time base only when the frequency changes, so a
       duty-only update does not clear `TSCNTSTP` or zero `TSCTR` on a running
       counter.
     * t3-gem-o1 registers eCAP1 as `/dev/ecap1` and eCAP2 as `/dev/ecap2`. 
Output
       pad selection is left to the board; the candidate pads collide with I2C0 
on
       this design.
   
   ### Impact
   
     * Is new feature added? **YES** — eCAP APWM support for AM67.
     * Impact on user? **NO** — new driver, opt-in by Kconfig.
     * Impact on build? **NO**.
     * Impact on hardware? **YES** — arch/arm/am67 and board t3-gem-o1.
     * Impact on documentation? **YES** — provided in this PR (second commit).
     * Impact on security? **NO**.
     * Impact on compatibility? **NO** — additive.
     * Anything else? Depends on PRs 3–5.
   
   ### Testing
   
   ```
   Build Host(s): Pardus GNU/Linux 25 (Debian 13 base), x86_64, host gcc 14
   Toolchain:     arm-none-eabi-gcc 14.2.1 20241119 (15:14.2.rel1-1)
   Target:        arm / TI AM67 (J722S) Cortex-R5F, board t3-gem-o1:nsh
   nuttx-apps:    5a7ab4200
   Loaded on the main-domain R5F by Linux remoteproc; console on UART-MAIN1.
   ```
   
   Testing logs before change: no eCAP support on this arch.
   
   The version string in the logs is from the tested build; the commits were
   GPG-signed afterwards, which rewrites hashes. The code is unchanged.
   
   Testing logs after change:
   
   ```
   make distclean && ./tools/configure.sh t3-gem-o1:nsh && make -j
     -> nuttx ELF 543332 bytes, 0 compiler warnings
   
   Console:
   nsh> pwm -p /dev/ecap1 -f 1000 -d 50 -t 1
   pwm_main: starting output with frequency: 1000 channel: 1 duty: 00007fff 
channel: 2 duty: 00007fff
   pwm_main: stopping output
   nsh> pwm -p /dev/ecap2 -f 1000 -d 50 -t 1
   pwm_main: starting output with frequency: 1000 channel: 1 duty: 00007fff 
channel: 2 duty: 00007fff
   pwm_main: stopping output
   nsh> pwm -p /dev/ecap1 -f 1000 -d 25 -t 2
   pwm_main: starting output with frequency: 1000 channel: 1 duty: 00003fff 
channel: 2 duty: 00007fff
   pwm_main: stopping output
   nsh> pwm -p /dev/ecap1 -f 1000 -d 75 -t 2
   pwm_main: starting output with frequency: 1000 channel: 1 duty: 0000bfff 
channel: 2 duty: 00007fff
   pwm_main: stopping output
   nsh>
   
   Test plan result:
   console_alive            PASS  prompt responsive
   version                  PASS  NuttX version 0.0.0 aaf0c2583d Sep 10 2026 
13:49:06 t3-gem-o1:nsh
   procfs                   PASS  procfs readable
   tasks                    PASS  2 task lines
   dev_nodes                PASS  all expected nodes present
   pwm_ecap1                PASS  /dev/ecap1 1 kHz / 50% for 1 s
   pwm_ecap2                PASS  /dev/ecap2 1 kHz / 50% for 1 s
   ecap_duty_only           PASS  25% then 75% at 1 kHz accepted
   
   PASS=8
   ```
   
   Measured time base, captured 2026-09-11, read back from the A53 over
   `/dev/mem` while NuttX drives the output. 
   
   ```
   NuttX:  nsh> pwm -p /dev/ecap1 -f 1000 -d 50 -t 25 &
   
   A53, while that is running (eCAP registers are 32-bit natively):
   
     /dev/ecap1 @ 0x23110000   APRD = 124999, ACMP = 62498
     /dev/ecap2 @ 0x23120000   APRD = 124999, ACMP = 62498
   
     frequency = 125 MHz / (124999 + 1) = 1000.00 Hz
     duty      = 62498 / 125000         = 49.998 %
   
     TSCTR sampled twice 0.4 s apart: 12959 -> 109982 (ecap1) and
     67938 -> 93142 (ecap2), so the counter is free-running.
   
   This is also the direct evidence for the duty-only path above: the eCAP
   clock is FICLK/2 of the EPWM's, and the 125000-tick period confirms the
   125 MHz figure the driver assumes.
   ```
   
   ### PR verification Self-Check
   
     * [x] This PR introduces only one functional change.
     * [x] I have updated all required description fields above.
     * [x] My PR adheres to Contributing Guidelines and Documentation.
     * [ ] My PR is still work in progress (not ready for review).
     * [x] My PR is ready for review and can be safely merged into a codebase.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to