1.. zephyr:board:: frdm_k22f 2 3Overview 4******** 5 6The Freedom-K22F is an ultra-low-cost development platform for Kinetis K22 7MCUs. 8 9- Form-factor compatible with the Arduino R3 pin layout 10- Peripherals enable rapid prototyping, including a 6-axis digital 11 accelerometer and magnetometer to create full eCompass capabilities, a 12 tri-colored LED and 2 user push-buttons for direct interaction, a optional 13 microSD card slot, and headers for use with Bluetooth* and 2.4 GHz radio 14 add-on modules 15- OpenSDAv2, the NXP open source hardware embedded serial and debug adapter 16 running an open source bootloader, offers options for serial communication, 17 flash programming, and run-control debugging 18 19Hardware 20******** 21 22- MK22FN512VLH12 (120 MHz, 512 KB flash memory, 128 KB RAM, low-power, 23 crystal-less USB, and 64 pin Low profile Quad Flat Package (LQFP)) 24- Dual role USB interface with micro-B USB connector 25- RGB LED 26- FXOS8700CQ accelerometer and magnetometer 27- Two user push buttons 28- Flexible power supply option - OpenSDAv2 USB, Kinetis K22 USB, and external source 29- Easy access to MCU input/output through Arduino* R3 compatible I/O connectors 30- Programmable OpenSDAv2 debug circuit supporting the CMSIS-DAP Interface 31 software that provides: 32 33 - Mass storage device (MSD) flash programming interface 34 - CMSIS-DAP debug interface over a driver-less USB HID connection providing 35 run-control debugging and compatibility with IDE tools 36 - Virtual serial port interface 37 - Open source CMSIS-DAP software project 38 39- Optional SDHC 40 41For more information about the K22F SoC and FRDM-K22F board: 42 43- `K22F Website`_ 44- `K22F Datasheet`_ 45- `K22F Reference Manual`_ 46- `FRDM-K22F Website`_ 47- `FRDM-K22F User Guide`_ 48- `FRDM-K22F Schematics`_ 49 50Supported Features 51================== 52 53The frdm_k22f board configuration supports the hardware features listed 54below. For additional features not yet supported, please also refer to the 55:zephyr:board:`frdm_k64f`, which is the superset board in NXP's Kinetis K series. 56NXP prioritizes enabling the superset board with NXP's Full Platform Support for 57Zephyr. Therefore, the frdm_k64f board may have additional features 58already supported, which can also be re-used on this frdm_k22f board: 59 60+-----------+------------+-------------------------------------+ 61| Interface | Controller | Driver/Component | 62+===========+============+=====================================+ 63| NVIC | on-chip | nested vector interrupt controller | 64+-----------+------------+-------------------------------------+ 65| SYSTICK | on-chip | systick | 66+-----------+------------+-------------------------------------+ 67| PINMUX | on-chip | pinmux | 68+-----------+------------+-------------------------------------+ 69| GPIO | on-chip | gpio | 70+-----------+------------+-------------------------------------+ 71| I2C | on-chip | i2c | 72+-----------+------------+-------------------------------------+ 73| SPI | on-chip | spi | 74+-----------+------------+-------------------------------------+ 75| WATCHDOG | on-chip | watchdog | 76+-----------+------------+-------------------------------------+ 77| ADC | on-chip | adc | 78+-----------+------------+-------------------------------------+ 79| PWM | on-chip | pwm | 80+-----------+------------+-------------------------------------+ 81| UART | on-chip | serial port-polling; | 82| | | serial port-interrupt | 83+-----------+------------+-------------------------------------+ 84| FLASH | on-chip | soc flash | 85+-----------+------------+-------------------------------------+ 86| USB | on-chip | USB device | 87+-----------+------------+-------------------------------------+ 88| SENSOR | off-chip | fxos8700 polling; | 89| | | fxos8700 trigger | 90+-----------+------------+-------------------------------------+ 91| RNGA | on-chip | entropy; | 92| | | random | 93+-----------+------------+-------------------------------------+ 94| FTFE | on-chip | flash programming | 95+-----------+------------+-------------------------------------+ 96 97The default configuration can be found in the defconfig file: 98 99:zephyr_file:`boards/nxp/frdm_k22f/frdm_k22f_defconfig` 100 101Other hardware features are not currently supported by the port. 102 103Connections and IOs 104=================== 105 106The K22F SoC has five pairs of pinmux/gpio controllers. 107 108+-------+-----------------+---------------------------+ 109| Name | Function | Usage | 110+=======+=================+===========================+ 111| PTA1 | GPIO | Red LED | 112+-------+-----------------+---------------------------+ 113| PTA2 | GPIO | Green LED | 114+-------+-----------------+---------------------------+ 115| PTD5 | GPIO | Blue LED | 116+-------+-----------------+---------------------------+ 117| PTC1 | GPIO | SW2 | 118+-------+-----------------+---------------------------+ 119| PTD0 | GPIO | FXOS8700 INT1 | 120+-------+-----------------+---------------------------+ 121| PTD1 | GPIO | FXOS8700 INT2 | 122+-------+-----------------+---------------------------+ 123| PTB17 | GPIO | SW3 | 124+-------+-----------------+---------------------------+ 125| PTE1 | UART1_RX | UART Console | 126+-------+-----------------+---------------------------+ 127| PTE0 | UART1_TX | UART Console | 128+-------+-----------------+---------------------------+ 129| PTD2 | UART2_RX | UART BT HCI | 130+-------+-----------------+---------------------------+ 131| PTD3 | UART2_TX | UART BT HCI | 132+-------+-----------------+---------------------------+ 133| PTC4 | SPI0_PCS0 | SPI | 134+-------+-----------------+---------------------------+ 135| PTD1 | SPI0_SCK | SPI | 136+-------+-----------------+---------------------------+ 137| PTD2 | SPI0_SOUT | SPI | 138+-------+-----------------+---------------------------+ 139| PTD3 | SPI0_SIN | SPI | 140+-------+-----------------+---------------------------+ 141| PTB2 | I2C0_SCL | I2C / FXOS8700 | 142+-------+-----------------+---------------------------+ 143| PTB3 | I2C0_SDA | I2C / FXOS8700 | 144+-------+-----------------+---------------------------+ 145 146System Clock 147============ 148 149The K22F SoC is configured to use the 8 MHz crystal oscillator on the board 150with the on-chip PLL to generate a 72 MHz system clock in its RUN mode. This 151clock was selected to allow for the maximum number of peripherals to be used 152with the crystal and PLL clocks. Other clock configurations are possible 153through NXP SDK currently. 154 155Serial Port 156=========== 157 158The K22F SoC has three UARTs. One is configured for the console, another for BT 159HCI, and the remaining are not used. 160 161USB 162=== 163 164The K22F SoC has a USB OTG (USBOTG) controller that supports both 165device and host functions through its micro USB connector (K22F USB). 166Only USB device function is supported in Zephyr at the moment. 167 168Programming and Debugging 169************************* 170 171Build and flash applications as usual (see :ref:`build_an_application` and 172:ref:`application_run` for more details). 173 174Configuring a Debug Probe 175========================= 176 177A debug probe is used for both flashing and debugging the board. This board is 178configured by default to use the :ref:`opensda-daplink-onboard-debug-probe`. 179 180Early versions of this board have an outdated version of the OpenSDA bootloader 181and require an update. Please see the `DAPLink Bootloader Update`_ page for 182instructions to update from the CMSIS-DAP bootloader to the DAPLink bootloader. 183 184Option 1: :ref:`opensda-daplink-onboard-debug-probe` (Recommended) 185------------------------------------------------------------------ 186 187Follow the instructions in :ref:`opensda-daplink-onboard-debug-probe` to program 188the `OpenSDA DAPLink FRDM-K22F Firmware`_. 189 190Install the :ref:`linkserver-debug-host-tools` and make sure they are in your 191search path. LinkServer works with the default CMSIS-DAP firmware included in 192the on-board debugger. 193 194Linkserver is the default for this board, ``west flash`` and ``west debug`` will 195call the linkserver runner. 196 197.. code-block:: console 198 199 west flash 200 201Alternatively, pyOCD can be used to flash and debug the board by using the 202``-r pyocd`` option with West. pyOCD is installed when you complete the 203:ref:`gs_python_deps` step in the Getting Started Guide. The runners supported 204by NXP are LinkServer and JLink. pyOCD is another potential option, but NXP 205does not test or support the pyOCD runner. 206 207Option 2: :ref:`opensda-jlink-onboard-debug-probe` 208-------------------------------------------------- 209 210Install the :ref:`jlink-debug-host-tools` and make sure they are in your search 211path. 212 213Follow the instructions in :ref:`opensda-jlink-onboard-debug-probe` to program 214the `Segger J-Link OpenSDA V2.1 Firmware`_. Note that Segger 215does provide an OpenSDA J-Link Board-Specific Firmware for this board, however 216it is not compatible with the DAPLink bootloader. 217 218Add the arguments ``-DBOARD_FLASH_RUNNER=jlink`` and 219``-DBOARD_DEBUG_RUNNER=jlink`` when you invoke ``west build`` to override the 220default runner from pyOCD to J-Link: 221 222.. zephyr-app-commands:: 223 :zephyr-app: samples/hello_world 224 :board: frdm_k22f 225 :gen-args: -DBOARD_FLASH_RUNNER=jlink -DBOARD_DEBUG_RUNNER=jlink 226 :goals: build 227 228Configuring a Console 229===================== 230 231Regardless of your choice in debug probe, we will use the OpenSDA 232microcontroller as a usb-to-serial adapter for the serial console. 233 234Connect a USB cable from your PC to J26. 235 236Use the following settings with your serial terminal of choice (minicom, putty, 237etc.): 238 239- Speed: 115200 240- Data: 8 bits 241- Parity: None 242- Stop bits: 1 243 244Flashing 245======== 246 247Here is an example for the :zephyr:code-sample:`hello_world` application. 248 249.. zephyr-app-commands:: 250 :zephyr-app: samples/hello_world 251 :board: frdm_k22f 252 :goals: flash 253 254Open a serial terminal, reset the board (press the SW1 button), and you should 255see the following message in the terminal: 256 257.. code-block:: console 258 259 ***** Booting Zephyr OS v2.0.0 ***** 260 Hello World! frdm_k22f 261 262Debugging 263========= 264 265Here is an example for the :zephyr:code-sample:`hello_world` application. 266 267.. zephyr-app-commands:: 268 :zephyr-app: samples/hello_world 269 :board: frdm_k22f 270 :goals: debug 271 272Open a serial terminal, step through the application in your debugger, and you 273should see the following message in the terminal: 274 275.. code-block:: console 276 277 ***** Booting Zephyr OS v2.0.0 ***** 278 Hello World! frdm_k22f 279 280.. _FRDM-K22F Website: 281 https://www.nxp.com/support/developer-resources/evaluation-and-development-boards/freedom-development-boards/mcu-boards/nxp-freedom-development-platform-for-kinetis-k22-mcus:FRDM-K22F 282 283.. _FRDM-K22F User Guide: 284 https://www.nxp.com/webapp/Download?colCode=FRDMK22FUG 285 286.. _FRDM-K22F Schematics: 287 https://www.nxp.com/webapp/Download?colCode=FRDM-K22F-SCH 288 289.. _K22F Website: 290 https://www.nxp.com/products/processors-and-microcontrollers/arm-based-processors-and-mcus/kinetis-cortex-m-mcus/k-seriesperformancem4/k2x-usb/kinetis-k22-120-mhz-cost-effective-full-speed-usb-microcontrollers-mcus-based-on-arm-cortex-m4-core:K22_120 291 292.. _K22F Datasheet: 293 https://www.nxp.com/docs/en/data-sheet/K22P121M120SF7.pdf 294 295.. _K22F Reference Manual: 296 https://www.nxp.com/docs/en/reference-manual/K22P121M120SF7RM.pdf 297 298.. _OpenSDA DAPLink FRDM-K22F Firmware: 299 https://www.nxp.com/downloads/en/snippets-boot-code-headers-monitors/k20dx_frdmk22f_if_crc_legacy_0x8000.bin 300 301.. _DAPLink Bootloader Update: 302 https://os.mbed.com/blog/entry/DAPLink-bootloader-update/ 303 304.. _Segger J-Link OpenSDA V2.1 Firmware: 305 https://www.segger.com/downloads/jlink/OpenSDA_V2_1.bin 306