Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

SimplePublish for SAM C21 Xplained Pro

The QSL includes a SimplePublish example for the Atmel Atmel SAM C21 Xplained Pro evaluation kit. This is given as an Atmel Studio 7 project based on the Atmel Software Framework (ASF).

The main.c code itself is similar to the one for the Raspberry Pi, 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). A yellow LED on the Xplained Pro board is also toggled to indicate whether the mote has connected to a network or not.

Info

The example was developed on Atmel Studio Version 7.0.1006 with ASF version 3.32.0.

...

Note

Windows is the only supported OS for the latest Atmel Studio 7.

Tip

ASF is included in Atmel Studio 7 and does not require a specific download, but you can use the Extension Manager (Tools->Extension Manager) to update it.

Prepare the SAM C21 Xplained Pro

...

The Xplained Pro has three extension headers (EXT1, EXT2, EXT3) with pins as listed in Table 7: Connect the mote to one of the headers, as per the mapping in Table 8. In Figure 6 you can see the mote connected to EXT1, but it does not matter which one you use: The pins for UART RX/TX on all three headers are connected to the same pins on the SAM C21. 


Warning

Long cables between the mote and Xplained Pro may corrupt the API bus communication.

Section
Column
width30%

Anchor
tab_xplainedExtHeader
tab_xplainedExtHeader
Name

Pin #Name
ID12GND
ADC+34ADC-
GPIO056

GPIO1

PWM+78PWM-
IRQ910SPI_SS_B
TWI_SDA1112TWI_SCL
UART_RX1314UART_TX
SPI_SS_A1516SPI_MOSI
SPI_MISO1718SPI_SCK
GND1920VCC

Table 7: Xplained Pro Standard Extention Header.

Column
width30%

Anchor
tab_xplained2MoteMapping
tab_xplained2MoteMapping
Xplained Pro

Mote
VCCVBAT
GNDGND
UART_TXRX
UART_RXTX
GNDRX RTSn
GNDTX CTSn

Table 8: Xplained Pro to mote pin mapping.

...

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 5 and Figure 6), and is used to program, debug and power the board.

...

Tip

You can (de)activate debug and log messages with the NDEBUG and NLOG defines in dn_debug.h (located in sm_qsl/).

 


Compile and Run

Navigate to the SimplePublish example directory at examples/samc21_xplained_pro/SimplePublish/ and open the SimplePublish.atsln solution file in Atmel Studio 7. This should open the project with everything set up for you. Since the Xplained Pro has an embedded debugger, you do not have to select any tool: Atmel Studio should detect that the board is connected via USB.

...

  1. Open the ASF Wizard: ASF > ASF Wizard (Ctrl+W)
  2. Select the correct project in the drop down menu (if not already selected).
    You should now see two windows with Available vs Selected Modules.
  3. Select and Add >> all the modules listed in Table 9.

    Note

    Make sure to select the correct mode when adding certain modules (you can change the mode of already selected modules too).

  4.  Press Apply.

...


Name

Anchor
tab_ASFmodules
tab_ASFmodules

TypeModeComment
Generic board supportDriver 
Selected by default
Delay routinesServicecycleUsed to implement dn_sleep_ms
PORT - GPIO Pin ControlDriver 
Selected by default
RTC - Real Time Counter DriverDrivercount_polledUsed to implement dn_time_ms
SYSTEM - Core System DriverDriver 
Selected by default
WDT - Watchdog TimerDrivercallbackUsed to implement watchdog functionality (optional)

...

Finally, you need to dive into the serial port configuration in serial.h and serial.c and make any necessary adaptations. Consult the datasheet of your platform for details (look for SERCOM USART).