1.. zephyr:board:: samr21_xpro 2 3Overview 4******** 5 6The SAM R21 Xplained Pro is a compact evaluation board by Atmel featuring a 7SAMR21G18A SoC. The SoC includes a SAMR21 ARM Cortex-M0+ micro-controller 8bundled with Atmel's AT86RF233, a 2.4GHz IEEE802.15.4 compatible radio. 9The kit includes Atmel’s Embedded Debugger (EDBG), which provides a full 10debug interface without the need for additional hardware. 11 12Hardware 13******** 14 15- SAMR21G18A ARM Cortex-M0+ processor at 48 MHz 16- 32.768 kHz crystal oscillator 17- 256 KiB flash memory and 32 KiB of RAM 18- One yellow user LED 19- One mechanical user push button 20- One reset button 21- On-board USB based EDBG unit with serial console 22 23Supported Features 24================== 25 26The samr21_xpro board configuration supports the following hardware 27features: 28 29+-----------+------------+--------------------------------------+ 30| Interface | Controller | Driver/Component | 31+===========+============+======================================+ 32| NVIC | on-chip | nested vector interrupt controller | 33+-----------+------------+--------------------------------------+ 34| SYSTICK | on-chip | systick | 35+-----------+------------+--------------------------------------+ 36| WDT | on-chip | Watchdog | 37+-----------+------------+--------------------------------------+ 38| GPIO | on-chip | I/O ports | 39+-----------+------------+--------------------------------------+ 40| PWM | on-chip | Pulse Width Modulation | 41+-----------+------------+--------------------------------------+ 42| USART | on-chip | Serial ports | 43+-----------+------------+--------------------------------------+ 44| SPI | on-chip | Serial Peripheral Interface ports | 45+-----------+------------+--------------------------------------+ 46| I2C | on-chip | I2C Peripheral Interface ports | 47+-----------+------------+--------------------------------------+ 48 49Other hardware features are not currently supported by Zephyr. 50 51The default configuration can be found in the Kconfig 52:zephyr_file:`boards/atmel/sam0/samr21_xpro/samr21_xpro_defconfig`. 53 54Pin Mapping 55=========== 56 57The SAM R21 Xplained Pro evaluation kit has 3 GPIO controllers. These 58controllers are responsible for pin muxing, input/output, pull-up, etc. 59 60For more details please refer to `SAM R21 Family Datasheet`_ and the `SAM R21 61Xplained Pro Schematic`_. 62 63.. image:: img/ATSAMR21-XPRO-pinout.jpg 64 :align: center 65 :alt: SAMR21-XPRO-pinout 66 67Default Zephyr Peripheral Mapping: 68---------------------------------- 69- SERCOM0 USART TX : PA5 70- SERCOM0 USART RX : PA4 71- SERCOM1 I2C SDA : PA16 72- SERCOM1 I2C SCL : PA17 73- SERCOM5 SPI MISO : PB02 74- SERCOM5 SPI MOSI : PB22 75- SERCOM5 SPI SCK : PB23 76- GPIO SPI CS : PB03 77- GPIO/PWM LED0 : PA19 78 79System Clock 80============ 81 82The SAMR21 MCU is configured to use the 32.768 kHz external oscillator 83with the on-chip PLL generating the 48 MHz system clock. 84 85Serial Port 86=========== 87 88The SAMR21 MCU has six SERCOM based USARTs with two configured as USARTs in 89this BSP. SERCOM0 is the default Zephyr console. 90 91- SERCOM0 115200 8n1 connected to the onboard Atmel Embedded Debugger (EDBG) 92 93PWM 94=== 95 96The SAMR21 MCU has 3 TCC based PWM units with up to 4 outputs each and a 97period of 24 bits or 16 bits. If :code:`CONFIG_PWM_SAM0_TCC` is enabled then 98LED0 is driven by TCC0 instead of by GPIO. 99 100SPI Port 101======== 102 103The SAMR21 MCU has 6 SERCOM based SPIs. 104 105- SERCOM5 is exposed via Xplained Pro Standard Extension Header 106 107I2C Port 108======== 109 110When connecting an I2C device and a logic analyzer to an I2C port at the same 111time, the internal pull-up resistors are not sufficient for stable bus 112operation. You probably have to connect external pull-ups to both bus lines. 10K 113is a good value to start with. 114 115- SERCOM1 is exposed via Xplained Pro Standard Extension Header 116 117Radio 118===== 119 120The SAMR21 SoC includes an on-chip AT86RF233 radio. It is internally 121connected via SPI and some GPIO pins and behaves the same way as 122externally connected SPI devices. 123 124+-------------+------------------------------------------------------------------------------------------+ 125| Sensor | AT86RF233 | 126+=============+==========================================================================================+ 127| Type | 2.4GHz IEEE802.15.4 radio | 128+-------------+------------------------------------------------------------------------------------------+ 129| Vendor | Atmel | 130+-------------+------------------------------------------------------------------------------------------+ 131| Datasheet |`Datasheet <http://www.atmel.com/images/atmel-8351-mcu_wireless-at86rf233_datasheet.pdf>`_| 132+-------------+------------------------------------------------------------------------------------------+ 133| connected to| SPI_0 | 134+-------------+------------------------------------------------------------------------------------------+ 135| Pin Config: | 136+-------------+------------------------------------------------------------------------------------------+ 137| Device | SERCOM4 | 138+-------------+------------------------------------------------------------------------------------------+ 139| MOSI | PB30 (OUT, SPI MOSI) | 140+-------------+------------------------------------------------------------------------------------------+ 141| MISO | PC19 (IN, SPI MISO) | 142+-------------+------------------------------------------------------------------------------------------+ 143| SCLK | PC18 (OUT, SPI SCLK) | 144+-------------+------------------------------------------------------------------------------------------+ 145| CS | PB31 (OUT, GPIO output) | 146+-------------+------------------------------------------------------------------------------------------+ 147| IRQ | PB00 (IN, GPIO external interrupt) | 148+-------------+------------------------------------------------------------------------------------------+ 149| RSTN | PB15 (OUT, GPIO output) | 150+-------------+------------------------------------------------------------------------------------------+ 151| SLP_TR | PA20 (OUT, GPIO output) | 152+-------------+------------------------------------------------------------------------------------------+ 153 154Zephyr provide several samples that can use this technology. You can check 155:zephyr:code-sample:`wpan-serial` example as starting points. 156Another good test can be done with IPv6 by using the server/client 157echo demo. More information at :zephyr:code-sample:`sockets-echo-server` and 158:zephyr:code-sample:`sockets-echo-client`. 159 160Programming and Debugging 161************************* 162 163The SAM R21 Xplained Pro comes with a Atmel Embedded Debugger (EDBG). This 164provides a debug interface to the SAMR21 chip and is supported by 165OpenOCD. 166 167Flashing 168======== 169 170#. Build the Zephyr kernel and the :zephyr:code-sample:`hello_world` sample application: 171 172 .. zephyr-app-commands:: 173 :zephyr-app: samples/hello_world 174 :board: samr21_xpro 175 :goals: build 176 :compact: 177 178#. Connect the SAM R21 Xplained Pro to your host computer using the USB debug 179 port. 180 181#. Run your favorite terminal program to listen for output. Under Linux the 182 terminal should be :code:`/dev/ttyACM0`. For example: 183 184 .. code-block:: console 185 186 $ minicom -D /dev/ttyACM0 -o 187 188 The -o option tells minicom not to send the modem initialization 189 string. Connection should be configured as follows: 190 191 - Speed: 115200 192 - Data: 8 bits 193 - Parity: None 194 - Stop bits: 1 195 196#. To flash an image: 197 198 .. zephyr-app-commands:: 199 :zephyr-app: samples/hello_world 200 :board: samr21_xpro 201 :goals: flash 202 :compact: 203 204 You should see "Hello World! samr21_xpro" in your terminal. 205 206References 207********** 208 209.. target-notes:: 210 211.. _Microchip website: 212 http://www.microchip.com/DevelopmentTools/ProductDetails.aspx?PartNO=ATSAMR21-XPRO 213 214.. _SAM R21 Family Datasheet: 215 http://ww1.microchip.com/downloads/en/devicedoc/sam-r21_datasheet.pdf 216 217.. _SAM R21 Xplained Pro Schematic: 218 http://ww1.microchip.com/downloads/en/DeviceDoc/SAMR21-Xplained-Pro_Design-Documentation.zip 219