1.. _nrf9160dk_nrf52840:
2
3nRF9160 DK - nRF52840
4#####################
5
6Overview
7********
8
9The nRF52840 SoC on the nRF9160 DK (PCA10090) hardware provides support for the
10Nordic Semiconductor nRF52840 ARM Cortex-M4F CPU and the following devices:
11
12* CLOCK
13* FLASH
14* :abbr:`GPIO (General Purpose Input Output)`
15* :abbr:`MPU (Memory Protection Unit)`
16* :abbr:`NVIC (Nested Vectored Interrupt Controller)`
17* :abbr:`PWM (Pulse Width Modulation)`
18* RADIO (Bluetooth Low Energy and 802.15.4)
19* :abbr:`RTC (nRF RTC System Clock)`
20* Segger RTT (RTT Console)
21* :abbr:`UART (Universal asynchronous receiver-transmitter)`
22* :abbr:`WDT (Watchdog Timer)`
23
24The nRF52840 SoC does not have any connection to the any of the LEDs,
25buttons, switches, and Arduino pin headers on the nRF9160 DK board. It is,
26however, possible to route some of the pins of the nRF52840 SoC to the nRF9160
27SiP.
28
29More information about the board can be found at
30the `Nordic Low power cellular IoT`_ website.
31The `Nordic Semiconductor Infocenter`_
32contains the processor's information and the datasheet.
33
34
35Hardware
36********
37
38The nRF9160 DK has two external oscillators. The frequency of
39the slow clock is 32.768 kHz. The frequency of the main clock
40is 32 MHz.
41
42Supported Features
43==================
44
45The nrf9160dk_nrf52840 board configuration supports the following
46hardware features:
47
48+-----------+------------+----------------------+
49| Interface | Controller | Driver/Component     |
50+===========+============+======================+
51| CLOCK     | on-chip    | clock_control        |
52+-----------+------------+----------------------+
53| FLASH     | on-chip    | flash                |
54+-----------+------------+----------------------+
55| GPIO      | on-chip    | gpio                 |
56+-----------+------------+----------------------+
57| MPU       | on-chip    | arch/arm             |
58+-----------+------------+----------------------+
59| NVIC      | on-chip    | arch/arm             |
60+-----------+------------+----------------------+
61| PWM       | on-chip    | pwm                  |
62+-----------+------------+----------------------+
63| RADIO     | on-chip    | Bluetooth,           |
64|           |            | ieee802154           |
65+-----------+------------+----------------------+
66| RTC       | on-chip    | system clock         |
67+-----------+------------+----------------------+
68| RTT       | Segger     | console              |
69+-----------+------------+----------------------+
70| UART      | on-chip    | serial               |
71+-----------+------------+----------------------+
72| WDT       | on-chip    | watchdog             |
73+-----------+------------+----------------------+
74
75Programming and Debugging
76*************************
77
78Applications for the ``nrf9160dk_nrf52840`` board configuration can be
79built and flashed in the usual way (see :ref:`build_an_application`
80and :ref:`application_run` for more details).
81
82Make sure that the PROG/DEBUG switch on the DK is set to nRF52.
83
84Flashing
85========
86
87Follow the instructions in the :ref:`nordic_segger` page to install
88and configure all the necessary software. Further information can be
89found in :ref:`nordic_segger_flashing`. Then build and flash
90applications as usual (see :ref:`build_an_application` and
91:ref:`application_run` for more details).
92
93Remember to set the PROG/DEBUG switch on the DK to nRF52.
94
95See the following example for the :ref:`hello_world` application.
96
97First, run your favorite terminal program to listen for output.
98
99.. code-block:: console
100
101   $ minicom -D <tty_device> -b 115200
102
103Replace :code:`<tty_device>` with the port where the nRF52840 SoC is connected
104to. Usually, under Linux it will be ``/dev/ttyACM1``. The ``/dev/ttyACM0``
105port is connected to the nRF9160 SiP on the board.
106
107Then build and flash the application in the usual way.
108
109.. zephyr-app-commands::
110   :zephyr-app: samples/hello_world
111   :board: nrf9160dk_nrf52840
112   :goals: build flash
113
114Debugging
115=========
116
117Refer to the :ref:`nordic_segger` page to learn about debugging Nordic boards
118with a Segger IC.
119
120Remember to set the PROG/DEBUG switch on the DK to nRF52.
121
122.. _nrf9160dk_board_controller_firmware:
123
124Board controller firmware
125*************************
126
127The board controller firmware is a small snippet of code that takes care of
128routing specific pins of the nRF9160 SiP to different components on the DK,
129such as LEDs and buttons, UART interfaces (VCOMx) of the interface MCU, and
130specific nRF52840 SoC pins.
131
132.. note::
133   In nRF9160 DK revisions earlier than v0.14.0, nRF9160 signals routed to
134   other components on the DK are not simultaneously available on the DK
135   connectors.
136
137When compiling a project for nrf9160dk_nrf52840, the board controller firmware
138will be compiled and run automatically after the Kernel has been initialized.
139
140By default, the board controller firmware will route the following:
141
142+--------------------------------+----------------------------------+
143| nRF9160 pins                   | Routed to                        |
144+================================+==================================+
145| P0.26, P0.27, P0.28, and P0.29 | VCOM0                            |
146+--------------------------------+----------------------------------+
147| P0.01, P0.00, P0.15, and P0.14 | VCOM2                            |
148+--------------------------------+----------------------------------+
149| P0.02                          | LED1                             |
150+--------------------------------+----------------------------------+
151| P0.03                          | LED2                             |
152+--------------------------------+----------------------------------+
153| P0.04                          | LED3                             |
154+--------------------------------+----------------------------------+
155| P0.05                          | LED4                             |
156+--------------------------------+----------------------------------+
157| P0.08                          | Switch 1                         |
158+--------------------------------+----------------------------------+
159| P0.09                          | Switch 2                         |
160+--------------------------------+----------------------------------+
161| P0.06                          | Button 1                         |
162+--------------------------------+----------------------------------+
163| P0.07                          | Button 2                         |
164+--------------------------------+----------------------------------+
165| P0.17, P0.18, and P0.19        | Arduino pin headers              |
166+--------------------------------+----------------------------------+
167| P0.21, P0.22, and P0.23        | Trace interface                  |
168+--------------------------------+----------------------------------+
169| COEX0, COEX1, and COEX2        | COEX interface                   |
170+--------------------------------+----------------------------------+
171
172For a complete list of all the routing options available,
173see the `nRF9160 DK board control section in the nRF9160 DK User Guide`_.
174
175If you want to route some of the above pins differently or enable any of the
176other available routing options, enable or disable the devicetree node that
177represents the analog switch that provides the given routing.
178
179The following devicetree nodes are defined for the analog switches present
180on the nRF9160 DK:
181
182+------------------------------------+------------------------------+
183| Devicetree node label              | Analog switch name           |
184+====================================+==============================+
185| ``vcom0_pins_routing``             | nRF91_UART1 (nRF91_APP1)     |
186+------------------------------------+------------------------------+
187| ``vcom2_pins_routing``             | nRF91_UART2 (nRF91_APP2)     |
188+------------------------------------+------------------------------+
189| ``led1_pin_routing``               | nRF91_LED1                   |
190+------------------------------------+------------------------------+
191| ``led2_pin_routing``               | nRF91_LED2                   |
192+------------------------------------+------------------------------+
193| ``led3_pin_routing``               | nRF91_LED3                   |
194+------------------------------------+------------------------------+
195| ``led4_pin_routing``               | nRF91_LED4                   |
196+------------------------------------+------------------------------+
197| ``switch1_pin_routing``            | nRF91_SWITCH1                |
198+------------------------------------+------------------------------+
199| ``switch2_pin_routing``            | nRF91_SWITCH2                |
200+------------------------------------+------------------------------+
201| ``button1_pin_routing``            | nRF91_BUTTON1                |
202+------------------------------------+------------------------------+
203| ``button2_pin_routing``            | nRF91_BUTTON2                |
204+------------------------------------+------------------------------+
205| ``nrf_interface_pins_0_2_routing`` | nRF_IF0-2_CTRL (nRF91_GPIO)  |
206+------------------------------------+------------------------------+
207| ``nrf_interface_pins_3_5_routing`` | nRF_IF3-5_CTRL (nRF91_TRACE) |
208+------------------------------------+------------------------------+
209| ``nrf_interface_pins_6_8_routing`` | nRF_IF6-8_CTRL (nRF91_COEX)  |
210+------------------------------------+------------------------------+
211
212When building for the DK revision 0.14.0 or later, you can use the following
213additional nodes (see :ref:`application_board_version` for information how to
214build for specific revisions of the board):
215
216+------------------------------------+------------------------------+
217| Devicetree node label              | Analog switch name           |
218+====================================+==============================+
219| ``nrf_interface_pin_9_routing``    | nRF_IF9_CTRL                 |
220+------------------------------------+------------------------------+
221| ``io_expander_pins_routing``       | IO_EXP_EN                    |
222+------------------------------------+------------------------------+
223| ``external_flash_pins_routing``    | EXT_MEM_CTRL                 |
224+------------------------------------+------------------------------+
225
226For example, if you want to enable the optional routing for the nRF9160 pins
227P0.17, P0.18, and P0.19 so that they are routed to nRF52840 pins P0.17, P0.20,
228and P0.15, respectively, add the following in the devicetree overlay in your
229application:
230
231.. code-block:: devicetree
232
233   &nrf_interface_pins_0_2_routing {
234           status = "okay";
235   };
236
237And if you want to, for example, disable routing for the VCOM2 pins, add the
238following:
239
240.. code-block:: devicetree
241
242   &vcom2_pins_routing {
243           status = "disabled";
244   };
245
246A few helper .dtsi files are provided in the directories
247:zephyr_file:`boards/arm/nrf9160dk_nrf52840/dts` and
248:zephyr_file:`boards/arm/nrf9160dk_nrf9160/dts`. They can serve as examples of
249how to configure and use the above routings. You can also include them from
250respective devicetree overlay files in your applications to conveniently
251configure the signal routing between nRF9160 and nRF52840 on the nRF9160 DK.
252For example, to use ``uart1`` on both these chips for communication between
253them, add the following line in the overlays for applications on both sides:
254
255.. code-block:: devicetree
256
257   #include <nrf9160dk_uart1_on_if0_3.dtsi>
258
259References
260**********
261
262.. target-notes::
263.. _Nordic Low power cellular IoT: https://www.nordicsemi.com/Products/Low-power-cellular-IoT
264.. _Nordic Semiconductor Infocenter: https://infocenter.nordicsemi.com
265.. _J-Link Software and documentation pack: https://www.segger.com/jlink-software.html
266.. _nRF9160 DK board control section in the nRF9160 DK User Guide: https://infocenter.nordicsemi.com/topic/ug_nrf91_dk/UG/nrf91_DK/board_controller.html
267