1.. zephyr:board:: twr_kv58f220m
2
3Overview
4********
5
6The TWR-KV58F220M is a development board for NXP Kinetis KV5x 32-bit
7MCU-based platforms. The onboard OpenSDAv2 serial and debug adapter,
8running an open source bootloader, offers options for serial
9communication, flash programming, and run-control debugging.
10
11Hardware
12********
13
14- MKV58F1M0VLQ24 MCU (up to 240 MHz, 1 MB flash memory, 256 KB RAM,
15  and 144 Low profile Quad Flat Package (LQFP))
16- 1.8 V or 3.3 V MCU operation
17- 6-axis FXOS8700CQ digital accelerometer and magnetometer
18- Four user LEDs
19- Four user push-buttons
20- Potentiometer
21- Two general purpose TWRPI headers
22- Motor pin header
23
24For more information about the KV5x SoC and the TWR-KV58F220M board, see
25these NXP reference documents:
26
27- `KV5x Website`_
28- `KV5x Datasheet`_
29- `KV5x Reference Manual`_
30- `TWR-KV58F220M Website`_
31- `TWR-KV58F220M User Guide`_
32- `TWR-KV58F220M Schematics`_
33
34Supported Features
35==================
36
37The twr_kv58f220m board configuration supports the following hardware
38features:
39
40+-----------+------------+-------------------------------------+
41| Interface | Controller | Driver/Component                    |
42+===========+============+=====================================+
43| NVIC      | on-chip    | nested vector interrupt controller  |
44+-----------+------------+-------------------------------------+
45| SYSTICK   | on-chip    | systick                             |
46+-----------+------------+-------------------------------------+
47| PINMUX    | on-chip    | pinmux                              |
48+-----------+------------+-------------------------------------+
49| GPIO      | on-chip    | gpio                                |
50+-----------+------------+-------------------------------------+
51| UART      | on-chip    | serial port-polling;                |
52|           |            | serial port-interrupt               |
53+-----------+------------+-------------------------------------+
54| FLASH     | on-chip    | soc flash                           |
55+-----------+------------+-------------------------------------+
56| I2C       | on-chip    | i2c                                 |
57+-----------+------------+-------------------------------------+
58| SENSOR    | off-chip   | fxos8700 polling;                   |
59|           |            | fxos8700 trigger                    |
60+-----------+------------+-------------------------------------+
61| SPI       | on-chip    | spi                                 |
62+-----------+------------+-------------------------------------+
63| ADC       | on-chip    | adc                                 |
64+-----------+------------+-------------------------------------+
65
66The default configuration can be found in the defconfig file:
67:zephyr_file:`boards/nxp/twr_kv58f220m/twr_kv58f220m_defconfig`.
68
69Other hardware features are not currently supported by the port.
70
71System Clock
72============
73
74The KV58 SoC is configured to use the 50 MHz external oscillator on the
75board with the on-chip PLL to generate a 237.5 MHz system clock.
76
77Serial Port
78===========
79
80The KV58 SoC has six UARTs. UART0 is configured for the console. The
81remaining UARTs are not used.
82
83Accelerometer and magnetometer
84==============================
85
86The TWR-KV58F220M board by default only supports polling the FXOS8700
87accelerometer and magnetometer for sensor values
88(``CONFIG_FXOS8700_TRIGGER_NONE=y``).
89
90In order to support FXOS8700 triggers (interrupts), shunts must be placed on
91the jumpers ``J2`` and ``J9``. A trigger option also must be enabled in Kconfig
92(either ``CONFIG_FXOS8700_TRIGGER_GLOBAL_THREAD=y`` or
93``CONFIG_FXOS8700_TRIGGER_OWN_THREAD=y``).
94
95Programming and Debugging
96*************************
97
98Build and flash applications as usual (see :ref:`build_an_application` and
99:ref:`application_run` for more details).
100
101Configuring a Debug Probe
102=========================
103
104This board integrates an OpenSDA debug probe. However, it can currently only be
105used for flashing the KV58 SoC by copying the compiled firmware to the USB Mass
106Storage Device. The board cannot be debugged using the OpenSDA probe, since
107pyOCD does not support the target. The OpenSDA J-Link firmware (as of release
1082019-06-03) also cannot be used, since the flash algorithm for the KV58 seems to
109be broken at the time of writing.
110
111An external J-Link debug probe connected to the JTAG header J13 is used to debug
112the target.
113
114Install the :ref:`jlink-debug-host-tools` and make sure they are in your search
115path.
116
117.. zephyr-app-commands::
118   :zephyr-app: samples/hello_world
119   :tool: all
120   :board: twr_kv58f220m
121   :goals: build
122
123Configuring a Console
124=====================
125
126Even though the OpenSDA probe cannot be used for debugging, we will use it as a
127USB-to-serial adapter for the serial console.
128
129Connect a USB cable from your PC to J22.
130
131Use the following settings with your serial terminal of choice (minicom, putty,
132etc.):
133
134- Speed: 115200
135- Data: 8 bits
136- Parity: None
137- Stop bits: 1
138
139Flashing
140========
141
142Here is an example for the :zephyr:code-sample:`hello_world` application.
143
144.. zephyr-app-commands::
145   :zephyr-app: samples/hello_world
146   :board: twr_kv58f220m
147   :goals: flash
148
149Open a serial terminal, reset the board (press the SW1 button), and you should
150see the following message in the terminal:
151
152.. code-block:: console
153
154   ***** Booting Zephyr OS v1.14.0-xxx-gxxxxxxxxxxxx *****
155   Hello World! twr_kv58f220m
156
157Debugging
158=========
159
160Here is an example for the :zephyr:code-sample:`hello_world` application.
161
162.. zephyr-app-commands::
163   :zephyr-app: samples/hello_world
164   :board: twr_kv58f220m
165   :goals: debug
166
167Open a serial terminal, step through the application in your debugger, and you
168should see the following message in the terminal:
169
170.. code-block:: console
171
172   ***** Booting Zephyr OS v1.14.0-xxx-gxxxxxxxxxxxx *****
173   Hello World! twr_kv58f220m
174
175.. _TWR-KV58F220M Website:
176   https://www.nxp.com/TWR-KV58F220M
177
178.. _TWR-KV58F220M User Guide:
179   https://www.nxp.com/webapp/Download?colCode=TWRKV58F220MUG
180
181.. _TWR-KV58F220M Schematics:
182   https://www.nxp.com/webapp/Download?colCode=TWR-KV58F220M-SCH
183
184.. _KV5x Website:
185   https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/general-purpose-mcus/kv-series-cortex-m4-m0-plus-m7/kinetis-kv5x-240-mhz-motor-control-and-power-conversion-ethernet-mcus-based-on-arm-cortex-m7:KV5x
186
187.. _KV5x Datasheet:
188   https://www.nxp.com/docs/en/data-sheet/KV5XP144M240.pdf
189
190.. _KV5x Reference Manual:
191   https://www.nxp.com/webapp/Download?colCode=KV5XP144M240RM
192