SimplePublish for SAM C21 Xplained Pro
The QSL includes a SimplePublish example for the Atmel SAM C21 Xplained Pro evaluation kit. This is an Atmel Studio 7 project based on the Atmel Software Framework (ASF). The main.c code itself is similar to the one for RPi, with the addition of a watchdog timer and initialization of a second serial port to enable debug prints (the watchdog is for demonstration purposes only, and can be removed as the user see fit).
Although the code is written specifically for the ATSAMC21J18A on the SAM C21 Xplained Pro evaluation kit, it should be pretty straightforward to port it to similar architectures since ASF is used. Correctly configuring the available serial ports (SERCOM) in serial.c/.h should be the only thing that might require some adaptation.
Prepare Atmel Studio
Download and run the Atmel Studio web installer from the official download page, and follow the instructions. This will also install the necessary drivers for the embedded debugger on the Xplained Pro board.
Windows is the only supported OS for the latest Atmel Studio 7.
Prepare the SAM C21 Xplained Pro
Set Supply Voltage to 3.3 V
Make sure that the jumper on the 3-pin header labeled VCC_SEL is set to 3.3 V, as seen in Figure 1. This will select 3.3 V as the supply voltage for the ATSAMC21J18A, peripherals and extension headers, which is important as we will power the mote from the latter.
The supply voltage is by default set to 5.0 V, which will fry your mote instantly!
Figure 1: Xplained Pro VCC selection header.
Connect to Mote
Figure 2: Mote connected to the SAM C21 Xplained Pro.
The Xplained Pro has three extension headers (EXT1, EXT2, EXT3) with pins as listed in Table 1: Connect the mote to one of the headers as per the mapping in Table 2. In Figure 2 you can see the mote connected to EXT1, but it does not matter which one you use: The pins for UART RX/TX are all connected to the same pins on the SAM C21.
Long cables between the mote and Xplained Pro may corrupt the API bus communication.
Name | Pin # | Name | |
---|---|---|---|
ID | 1 | 2 | GND |
ADC+ | 3 | 4 | ADC- |
GPIO0 | 5 | 6 | GPIO1 |
PWM+ | 7 | 8 | PWM- |
IRQ | 9 | 10 | SPI_SS_B |
TWI_SDA | 11 | 12 | TWI_SCL |
UART_RX | 13 | 14 | UART_TX |
SPI_SS_A | 15 | 16 | SPI_MOSI |
SPI_MISO | 17 | 18 | SPI_SCK |
GND | 19 | 20 | VCC |
Table 1: Xplained Pro Standard Extention Header.
Xplained Pro | Mote |
---|---|
VCC | VBAT |
GND | GND |
UART_TX | RX |
UART_RX | TX |
GND | RX RTSn |
GND | TX CTSn |
Table 2: Xplained Pro to mote pin mapping.
Connect Debug USB to Computer
Connect a USB cable from your computer to the USB-micro port labeled DEBUG USB: This is the port on the top of the Xplained Pro board (visible in both Figure 1 and Figure 2), and is used to program, debug and power the board.
The debug USB also spawns a virtual serial port named EDBG Virtual COM Port. Make sure to note the name, e.g. COM4 in the example pictured below, as we will open a terminal on said port to see debug prints.
Open Debug Terminal
The SimplePublish example code will send all standard input/output (e.g. debug prints) through the serial port you identified in the previous section. Open your favourite serial terminal and connect to it with the following configurations:
- Baudrate: 115200
- Data Bits: 8
- Parity: None
- Stop Bits: 1
You probably have to restart the terminal whenever you disconnect/reconnect the debug USB to the Xplained Pro.