samples/basic/blinky_pwm/README.html · samples/basic/blinky_pwm/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · PWM

PWM Blinky

PWM period를 hardware 범위에 맞게 보정하며 4초마다 blinking frequency를 두 배 또는 절반으로 바꿉니다.

Official pathsamples/basic/blinky_pwm/README.html
Source filesamples/basic/blinky_pwm/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

pwm_led0 alias, 9개 board의 외부 LED 배선과 nRF52840 DK build·flash 명령을 설명합니다.

Range

1 Hz → 128 Hz

Alias

pwm_led0

Wiring

PWM1/2 · GPIO2

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 1193B44C773887CC98097211ADC88A36EC1083D21BA153F373B5F071172C164F
.. zephyr:code-sample:: pwm-blinky
   :name: PWM Blinky
   :relevant-api: pwm_interface

   Blink an LED using the PWM API.

Overview
********

This application blinks an LED using the :ref:`PWM API <pwm_api>`. See
:zephyr:code-sample:`blinky` for a GPIO-based sample.

The LED starts blinking at a 1 Hz frequency. The frequency doubles every 4
seconds until it reaches 128 Hz. The frequency will then be halved every 4
seconds until it returns to 1 Hz, completing a single blinking cycle. This
faster-then-slower blinking cycle then repeats forever.

Some PWM hardware cannot set the PWM period to 1 second to achieve the blinking
frequency of 1 Hz. This sample calibrates itself to what the hardware supports
at startup. The maximum PWM period is decreased appropriately until a value
supported by the hardware is found.

Requirements
************

The board must have an LED connected to a PWM output channel. The PWM
controlling this LED must be configured using the ``pwm_led0`` :ref:`devicetree
<dt-guide>` alias, usually in the :ref:`BOARD.dts file
<devicetree-in-out-files>`.

Wiring
******

No additional wiring is necessary if ``pwm_led0`` refers to hardware that is
already connected to an LED on the board.

In these other cases, however, manual wiring is necessary:

.. list-table::
   :header-rows: 1

   * - Board
     - Wiring
   * - :ref:`nucleo_f401re_board`
     - connect PWM2 (PA0) to an LED
   * - :ref:`nucleo_l476rg_board`
     - connect PWM2 (PA0) to an LED
   * - :ref:`stm32f4_disco_board`
     - connect PWM2 (PA0) to an LED
   * - :ref:`nucleo_f302r8_board`
     - connect PWM2 (PA0) to an LED
   * - :ref:`nucleo_f103rb_board`
     - connect PWM1 (PA8) to an LED
   * - :ref:`nucleo_wb55rg_board`
     - connect PWM1 (PA8) to an LED
   * - :ref:`esp32_devkitc_wroom`
     - connect GPIO2 to an LED
   * - :ref:`esp32s2_saola`
     - connect GPIO2 to an LED
   * - :ref:`esp32c3_devkitm`
     - connect GPIO2 to an LED

Building and Running
********************

To build and flash this sample for the :ref:`nrf52840dk_nrf52840`:

.. zephyr-app-commands::
   :zephyr-app: samples/basic/blinky_pwm
   :board: nrf52840dk/nrf52840
   :goals: build flash
   :compact:

Change ``nrf52840dk/nrf52840`` appropriately for other supported boards.

After flashing, the sample starts blinking the LED as described above. It also
prints information to the board's console.

Part 3

한국어 전문 번역

개요

이 application은 PWM API를 사용해 LED를 깜박입니다. GPIO 기반 example은 Blinky sample을 참조하십시오.

LED는 1 Hz로 깜박이기 시작합니다. 128 Hz에 도달할 때까지 4초마다 frequency가 두 배가 되고, 그다음 1 Hz로 돌아올 때까지 4초마다 절반으로 줄어 한 번의 blinking cycle을 마칩니다. 이 빠르게-느리게 깜박이는 cycle은 계속 반복됩니다.

일부 PWM hardware는 1 Hz blinking frequency를 얻기 위한 1초 PWM period를 설정할 수 없습니다. 이 sample은 시작할 때 hardware 지원 범위에 맞게 스스로 보정합니다. Hardware가 지원하는 값을 찾을 때까지 최대 PWM period를 적절히 줄입니다.

요구사항

Board에는 PWM output channel에 연결된 LED가 있어야 합니다. 이 LED를 제어하는 PWM은 일반적으로 BOARD.dts file에서 pwm_led0 Devicetree alias로 configuration해야 합니다.

배선

pwm_led0가 board에서 LED에 이미 연결된 hardware를 가리킨다면 추가 배선이 필요하지 않습니다. 다음 경우에는 직접 배선해야 합니다.

Board배선
nucleo_f401rePWM2(PA0)를 LED에 연결
nucleo_l476rgPWM2(PA0)를 LED에 연결
stm32f4_discoPWM2(PA0)를 LED에 연결
nucleo_f302r8PWM2(PA0)를 LED에 연결
nucleo_f103rbPWM1(PA8)를 LED에 연결
nucleo_wb55rgPWM1(PA8)를 LED에 연결
esp32_devkitc_wroomGPIO2를 LED에 연결
esp32s2_saolaGPIO2를 LED에 연결
esp32c3_devkitmGPIO2를 LED에 연결

Build와 실행

nrf52840dk/nrf52840용 sample은 다음과 같이 build하고 flash합니다.

west build -b nrf52840dk/nrf52840 samples/basic/blinky_pwm
west flash

다른 지원 board에서는 nrf52840dk/nrf52840을 알맞은 board 이름으로 바꾸십시오. Flash가 끝나면 앞서 설명한 방식으로 LED가 깜박이고 board console에도 정보가 출력됩니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.