Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 117 additions & 9 deletions Documentation/platforms/arm/ht32f491x3/boards/esk32/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ESK32 (HT32F49163)
The ESK32 is a development board based on the Holtek HT32F49163 MCU.
The current NuttX port targets the HT32F49163 device used on the
HT32F49163 development kit and focuses on a working serial-console NSH
configuration with basic board bring-up.
configuration with basic board bring-up plus timer-based PWM validation.

For additional hardware details, refer to Holtek's
`HT32F491x3 Starter Kit User Guide <https://www.holtek.com/webapi/106680/HT32F491x3_StarterKitUserManualv100.pdf>`_.
Expand All @@ -28,6 +28,7 @@ The current port provides:
* Boot and clock initialization for the ESK32 8 MHz external crystal
* System clock configured to 150 MHz
* USART1 serial console at 115200 8N1
* TMR3 PWM outputs exposed through ``/dev/pwm0`` .. ``/dev/pwm3``
* ``/bin`` mounted through ``binfs``
* ``/proc`` mounted through ``procfs``
* User LED registration through ``/dev/userleds``
Expand All @@ -41,6 +42,10 @@ applications:
* ``dumpstack``
* ``leds``

The ``esk32:pwm`` configuration keeps the same board bring-up and adds the
``pwm`` example application together with a board-level PWM device at
``/dev/pwm0`` .. ``/dev/pwm3``.

Buttons and LEDs
================

Expand Down Expand Up @@ -75,8 +80,12 @@ The current port uses the following MCU pins:
===== ========== ==========
Pin Signal Notes
===== ========== ==========
PA6 TMR3_CH1 ``/dev/pwm0`` output in ``esk32:pwm``
PA7 TMR3_CH2 ``/dev/pwm1`` output in ``esk32:pwm``
PA9 USART1_TX Default serial console TX
PA10 USART1_RX Default serial console RX
PB0 TMR3_CH3 ``/dev/pwm2`` output in ``esk32:pwm``
PB1 TMR3_CH4 ``/dev/pwm3`` output in ``esk32:pwm``
PD13 LED2 User LED, active-low
PD14 LED3 User LED, active-low
PD15 LED4 User LED, active-low
Expand Down Expand Up @@ -124,16 +133,72 @@ The following commands are useful for validating the current port:
When ``leds`` is executed, the example opens ``/dev/userleds`` and cycles
through the LED bitmasks supported by the board.

Current Limitations
===================
The ``esk32:pwm`` configuration also exposes ``/dev/pwm0`` through TMR3. The
default defconfig selects ``CONFIG_HT32F491X3_TMR3_CHANNEL=1``, so the PWM
signal is routed to ``PA6``. Probe ``PA6`` against board ``GND`` and run:

.. code-block:: console

nsh> pwm -f 1000 -d 50 -t 5

The current port is still intentionally small. In particular:
This command starts a 1 kHz PWM waveform with a 50% duty cycle for 5 seconds.
On the default channel that corresponds to a 1 ms period with a 500 us high
pulse on ``PA6``. A typical console log is:

* only the ``nsh`` board configuration is maintained
* only USART1 routing is described by the board port
* LEDs are supported, but board buttons are not yet implemented
* internal GPIO helpers exist, but there is not yet a board-level ``/dev/gpio``
test interface in this port
.. code-block:: console

nsh> pwm -f 1000 -d 50 -t 5
pwm_main: starting output with frequency: 1000 duty: 00007fff
pwm_main: stopping output

Peripheral Support
==================

+---------------------+---------+-------------------------------------+
| Peripheral | Support | Notes |
+=====================+=========+=====================================+
| Boot / Clock / IRQ | Yes | Board start-up, clock tree and tick |
+---------------------+---------+-------------------------------------+
| UART | Yes | USART1 console |
+---------------------+---------+-------------------------------------+
| GPIO | Partial | Internal helpers only |
+---------------------+---------+-------------------------------------+
| LEDs | Yes | ``USERLED`` and ``/dev/userleds`` |
+---------------------+---------+-------------------------------------+
| Buttons | No | |
+---------------------+---------+-------------------------------------+
| PWM | Yes | TMR3 exposed as ``/dev/pwm0`` |
+---------------------+---------+-------------------------------------+
| Pulse Counter | No | |
+---------------------+---------+-------------------------------------+
| Timers | Partial | OS tick and TMR3 PWM |
+---------------------+---------+-------------------------------------+
| SPI | No | |
+---------------------+---------+-------------------------------------+
| I2C | No | |
+---------------------+---------+-------------------------------------+
| ADC | No | |
+---------------------+---------+-------------------------------------+
| DAC | No | |
+---------------------+---------+-------------------------------------+
| CAN | No | |
+---------------------+---------+-------------------------------------+
| DMA | No | |
+---------------------+---------+-------------------------------------+
| RTC / ERTC | No | |
+---------------------+---------+-------------------------------------+
| I2S | No | |
+---------------------+---------+-------------------------------------+
| Watchdog | No | |
+---------------------+---------+-------------------------------------+
| USB Device | No | |
+---------------------+---------+-------------------------------------+
| USB Host | No | |
+---------------------+---------+-------------------------------------+
| External Interrupts | No | |
+---------------------+---------+-------------------------------------+
| Power Control | No | |
+---------------------+---------+-------------------------------------+

Configurations
==============
Expand Down Expand Up @@ -175,3 +240,46 @@ And the built-in applications can be listed with:
nsh
ostest
sh

pwm
---

This configuration enables the generic PWM framework, registers the TMR3
lower-half driver as ``/dev/pwm0`` .. ``/dev/pwm3``, and includes the ``pwm`` example
application for board-level validation.

Configure and build it from the ``nuttx`` directory:

.. code-block:: console

$ ./tools/configure.sh -l esk32:pwm
$ make olddefconfig
$ make -j

After flashing the image, the following command can be used from NSH to
validate PWM generation on ``/dev/pwm0``:

.. code-block:: console

nsh> pwm -f 1000 -d 50 -t 5

The expected result is a 1 kHz, 50% duty-cycle waveform on ``PA6`` for 5
seconds, followed by the application stopping the output. A typical console
log is:

.. code-block:: console

nsh> pwm -f 1000 -d 50 -t 5
pwm_main: starting output with frequency: 1000 duty: 00007fff
pwm_main: stopping output

The additional TMR3 outputs are also registered:

* ``/dev/pwm0``: ``PA6`` / TMR3_CH1
* ``/dev/pwm1``: ``PA7`` / TMR3_CH2
* ``/dev/pwm2``: ``PB0`` / TMR3_CH3
* ``/dev/pwm3``: ``PB1`` / TMR3_CH4

All four device nodes share the same underlying TMR3 instance, so they must
run at the same PWM frequency. Starting one channel at a different frequency
while another channel is active returns ``-EBUSY``.
4 changes: 4 additions & 0 deletions arch/arm/src/ht32f491x3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ list(
ht32f491x3_lowputc.c
ht32f491x3_serial.c)

if(CONFIG_PWM)
list(APPEND SRCS ht32f491x3_pwm.c)
endif()

if(CONFIG_ARCH_HAVE_CUSTOM_VECTORS)
list(APPEND SRCS arm_vectors.c)
endif()
Expand Down
Loading
Loading