1.. _nrf21540dk_nrf52840:
2
3nRF21540 DK
4###########
5
6Overview
7********
8The nRF21540 DK (PCA10112) shows possibility of the Nordic Semiconductor
9nRF21540 Front End Module connected with nRF52840 ARM Cortex-M4F CPU.
10The CPU provides support for the following devices:
11
12* :abbr:`ADC (Analog to Digital Converter)`
13* CLOCK
14* FLASH
15* :abbr:`GPIO (General Purpose Input Output)`
16* :abbr:`I2C (Inter-Integrated Circuit)`
17* :abbr:`MPU (Memory Protection Unit)`
18* :abbr:`NVIC (Nested Vectored Interrupt Controller)`
19* :abbr:`PWM (Pulse Width Modulation)`
20* RADIO (Bluetooth Low Energy and 802.15.4)
21* :abbr:`RTC (nRF RTC System Clock)`
22* Segger RTT (RTT Console)
23* :abbr:`SPI (Serial Peripheral Interface)`
24* :abbr:`UART (Universal asynchronous receiver-transmitter)`
25* :abbr:`USB (Universal Serial Bus)`
26* :abbr:`WDT (Watchdog Timer)`
27
28.. figure:: img/nrf21540dk_nrf52840.jpg
29     :align: center
30     :alt: nRF21540 DK
31
32     nRF21540 DK (Credit: Nordic Semiconductor)
33
34More information about the board can be found at the `nRF21540 website`_.
35`nRF21540 Product Specification`_ contains the processor's and front end
36module's information and the datasheet.
37
38Hardware
39********
40
41The nRF52840 on the nRF21540 DK has two external oscillators. The frequency
42of the slow clock is 32.768 kHz. The frequency of the main clock is 32 MHz.
43
44Supported Features
45==================
46
47The nrf21540dk/nrf52840 board configuration supports the following
48hardware features:
49
50+-----------+------------+----------------------+
51| Interface | Controller | Driver/Component     |
52+===========+============+======================+
53| ADC       | on-chip    | adc                  |
54+-----------+------------+----------------------+
55| CLOCK     | on-chip    | clock_control        |
56+-----------+------------+----------------------+
57| FLASH     | on-chip    | flash                |
58+-----------+------------+----------------------+
59| GPIO      | on-chip    | gpio                 |
60+-----------+------------+----------------------+
61| I2C(M)    | on-chip    | i2c                  |
62+-----------+------------+----------------------+
63| MPU       | on-chip    | arch/arm             |
64+-----------+------------+----------------------+
65| NVIC      | on-chip    | arch/arm             |
66+-----------+------------+----------------------+
67| PWM       | on-chip    | pwm                  |
68+-----------+------------+----------------------+
69| RADIO     | on-chip    | Bluetooth,           |
70|           |            | ieee802154           |
71+-----------+------------+----------------------+
72| RTC       | on-chip    | system clock         |
73+-----------+------------+----------------------+
74| RTT       | Segger     | console              |
75+-----------+------------+----------------------+
76| SPI(M/S)  | on-chip    | spi                  |
77+-----------+------------+----------------------+
78| UART      | on-chip    | serial               |
79+-----------+------------+----------------------+
80| USB       | on-chip    | usb                  |
81+-----------+------------+----------------------+
82| WDT       | on-chip    | watchdog             |
83+-----------+------------+----------------------+
84
85Other hardware features have not been enabled yet for this board.
86See `nRF52840 Product Specification`_ and `nRF21540 DK Hardware guide`_
87for a complete list of nRF21540 Development Kit board hardware features.
88
89Connections and IOs
90===================
91
92LED
93---
94
95* LED1 (green) = P0.13
96* LED2 (green) = P0.14
97* LED3 (green) = P0.15
98* LED4 (green) = P0.16
99
100Push buttons
101------------
102
103* BUTTON1 = SW1 = P0.11
104* BUTTON2 = SW2 = P0.12
105* BUTTON3 = SW3 = P0.24
106* BUTTON4 = SW4 = P0.25
107* BOOT = SW5 = boot/reset
108
109Front End Module
110----------------
111
112* MOSI        = P1.13
113* MISO        = P1.14
114* CLOCK       = P1.15
115* CHIP SELECT = P0.21
116* PDN         = P0.23
117* MODE        = P0.17
118* RXEN        = P0.19
119* ANTSEL      = P0.20
120* TXEN        = P0.22
121
122Programming and Debugging
123*************************
124
125Applications for the ``nrf21540dk/nrf52840`` board configuration can be built,
126flashed, and debugged in the usual way. See :ref:`build_an_application` and
127:ref:`application_run` for more details on building and running.
128
129Flashing
130========
131
132Follow the instructions in the :ref:`nordic_segger` page to install
133and configure all the necessary software. Further information can be
134found in :ref:`nordic_segger_flashing`. Then build and flash
135applications as usual (see :ref:`build_an_application` and
136:ref:`application_run` for more details).
137
138Here is an example for the :ref:`hello_world` application.
139
140First, run your favorite terminal program to listen for output.
141
142.. code-block:: console
143
144   $ minicom -D <tty_device> -b 115200
145
146Replace :code:`<tty_device>` with the port where the board nRF21540 DK
147can be found. For example, under Linux, :code:`/dev/ttyACM0`.
148
149Then build and flash the application in the usual way.
150
151.. zephyr-app-commands::
152   :zephyr-app: samples/hello_world
153   :board: nrf21540dk/nrf52840
154   :goals: build flash
155
156Debugging
157=========
158
159Refer to the :ref:`nordic_segger` page to learn about debugging Nordic boards with a
160Segger IC.
161
162
163Testing the LEDs and buttons in the nRF21540 DK
164***********************************************
165
166There are 2 samples that allow you to test that the buttons (switches) and LEDs on
167the board are working properly with Zephyr:
168
169.. code-block:: console
170
171   samples/basic/blinky
172   samples/basic/button
173
174You can build and flash the examples to make sure Zephyr is running correctly on
175your board. The button and LED definitions can be found in
176:zephyr_file:`boards/nordic/nrf21540dk/nrf21540dk_nrf52840.dts`.
177
178Changing UART1 pins
179*******************
180
181The following approach can be used when an application needs to use another set
182of pins for UART1:
183
1841. Add devicetree overlay file to the main directory of your application:
185
186   .. code-block:: devicetree
187
188      &pinctrl {
189         uart1_default_alt: uart1_default_alt {
190            group1 {
191               psels = <NRF_PSEL(UART_TX, 0, 14)>,
192                       <NRF_PSEL(UART_RX, 0, 16)>;
193            };
194         };
195         /* required if CONFIG_PM_DEVICE=y */
196         uart1_sleep_alt: uart1_sleep_alt {
197            group1 {
198               psels = <NRF_PSEL(UART_TX, 0, 14)>,
199                       <NRF_PSEL(UART_RX, 0, 16)>;
200               low-power-enable;
201            };
202         };
203      };
204
205      &uart1 {
206        pinctrl-0 = <&uart1_default_alt>;
207        /* if sleep state is not used, use /delete-property/ pinctrl-1; and
208         * skip the "sleep" entry.
209         */
210        pinctrl-1 = <&uart1_sleep_alt>;
211        pinctrl-names = "default", "sleep";
212      };
213
214   In the overlay file above, pin P0.16 is used for RX and P0.14 is used for TX
215
216See :ref:`set-devicetree-overlays` for further details.
217
218Selecting the pins
219==================
220
221Pins can be configured in the board pinctrl file. To see the available mappings,
222open the `nRF52840 Product Specification`_, chapter 7 'Hardware and Layout'.
223In the table 7.1.1 'aQFN73 ball assignments' select the pins marked
224'General purpose I/O'.  Note that pins marked as 'low frequency I/O only' can only be used
225in under-10KHz applications. They are not suitable for 115200 speed of UART.
226
227References
228**********
229
230.. target-notes::
231
232.. _nRF21540 DK Hardware guide: https://docs.nordicsemi.com/bundle/ug_nrf21540_dk/page/UG/nrf21540_DK/intro.html
233.. _J-Link Software and documentation pack: https://www.segger.com/jlink-software.html
234.. _nRF21540 website: https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF21540
235.. _nRF52840 Product Specification: https://docs.nordicsemi.com/bundle/ps_nrf52840/page/keyfeatures_html5.html
236.. _nRF21540 Product Specification: https://docs.nordicsemi.com/bundle/ps_nrf21540/page/keyfeatures_html5.html
237