dcsimg
Skip to end of metadata
Go to start of metadata

 

Purpose

This page is meant to help you get started with the ATmega256RFR2 Xplained Pro board from Atmel.

 

Description

The ATmega256RFR2 Xplained Pro development kit allows for complete evaluation of the ATmega256RFR2 dual purpose IC.  The ATmega256RFR2 integrates an 8-bit AVR microcontroller with a low power 2.4GHz RF transceiver.  It provides industry leading RF performance for single chip solutions with decreased power consumption.  Xplained Pro is the latest series of low-cost development boards for Atmel MCUs.  The Xplained Pro series shares a common form factor along with various daughter cards that are capable of interfacing with the Xplained Pro development boards.  The ATmegaRFR2 Xplained Pro board, specifically, is capable of interfacing with the I/O daughter card, the OLED daughter card, and the PROTO daughter card.  The ATmega256RFR2 Xplained Pro eval board comes with an on-board embedded debugger (EDBG) which enables the user to debug the RFR2 without needing an external debugger.  The EDBG also serves as a Data Gateway Interface (DGI) and Virtual COM Port (VCP).

ATmega256RFR2 Specs

 

Table of Specifications
Flash256 KB
EEPROM8 KB 
Max Freq16MHz
Serial CommSPI, TWI, UART
ADC Channels8 x 10b
Max Data Rate2Mb/s
TX Power3.5dBm
TX Power Consumption14.5mA
 RX Sensitivity-100dBm
 RX Power Consumption 12.5mA

Daughter Cards

I/O1 Daughter Card


 OLED1 Daughter Card

PROTO1 Daughter Card

 

Documentation

    ATmega256RFR2 Xplained Pro Board

    Xplained Pro Daughter Cards

Useful Downloads

  • Atmel Studio 6.1  -  must use Studio 6.1 or later for this board.  Previous revisions of Studio do not interface properly with the embedded debugger.
  • Atmel Lightweight Mesh (ALM)  -  Free, lowpower, proprietary mesh wireless network; software stack for AVR microcontrollers from Atmel.
  • BitCloud for megaRF  -  Free, ZigBee PRO wireless network software stack for megaRF devices.
  • Tera Term  -  Free open source terminal emulator; Useful for communicating with UART using keyboard characters.

Tutorials

These tutorials are put in order of difficulty with the first one being the easiest to understand.  If the reader has limited experience with Atmel products, it is recommended to perform each of the following tutorials in order.  If the reader already has fairly extensive experience with 8-bit AVR microcontrollers, feel free to jump to the Peer2Peer project to get started with wireless communication.  Once the reader feels comfortable with these tutorials, feel free to open some of the ATmega256RFR2 Xplained Pro example projects in ASF, as the ASF provides some additional wireless communication examples.

 

 Blinky LED

No set of tutorials would be complete without the standard Blinky LED tutorial.  Even though this IC is ultimately meant for wireless applications, it still implements an 8-bit AVR microcontroller, which means it has built in timers, interrupts, and GPIOs.  Though simple, the Blinky_LED project proves to be a useful tutorial to ensure the board is connected (and functioning) properly, the software development tool builds the project and programs the target properly, and gets the user going quickly with a very simple project.

Objectives

  • Introduce user to a simple "getting started" tutorial
  • Setup a basic 16-bit timer with interrupt
  • Toggle an LED based on timer interrupt execution

Requirements

  • One RFR2 Xplained Pro board with USB cable
  • PC with Atmel Studio 6.1 installed

Procedure

  1. Download the following Blinky_LED project for Atmel Studio 6.1.
  2. Extract the contents of the downloaded folder and open the Blinky_LED project in Atmel Studio 6.1.
  3. Connect the ATmegaRFR2 Xplained Pro board to the PC using the USB cable
    • Tip

      Navigate to:  Control Panel  ->  Device Manager

      Verify "EDBG Virtual COM Port" shows up under Ports (COM & LPT)

  4. This project bases its timing on a 1MHz system clock.  The RFR2 Xplained Pro board ships with the internal RC oscillator selected as the clock source and the CKDIV8 fuse programmed.  This creates a system clock of 1MHz.  The user should verify these settings:
    • In Atmel Studio, in the menu bar, navigate to:  Tools  ->  Device Programming
    • In the "Tool" dropdown, select "XPRO-EDB".  Select "ATmega256RFR2" in the "Device" dropdown.  Select "JTAG" as the interface and click "Apply". 
      • Note

        Studio 6.1 should auto-detect if the Embedded Debugger has the most up-to-date firmware on it.  The user may be prompted to update firmware upon reading the device

    • On the left side of the Device Programming dialog box, select "Fuses". 
    • Ensure that the CKDIV8 box is checked and the CKSEL_SUT option is "INTRCOS_6CK_65MS" (may have to scroll to view all fuses).  
    • Click "Program" and close the Device Programming dialog box.  The system should now be running off the internal RC oscillator at 1MHz if it wasn't already. 
    • Close the Device Programming dialog box.
  5. Save and build Blinky_LED in Atmel Studio 6.1.
  6. Program the RFR2 Xplained Pro board and verify the yellow on-board LED is toggling every half second.

The user is encouraged to try different delay times and/or different clock rates to become familiar with the timing system.


 

 Using the 16MHz Crystal

The ATmega256RFR2 differs from previous mega microcontrollers in the fact that it has a 16MHz internal RC oscillator instead of an 8MHz internal RC oscillator.  One would assume switching between the internal 16MHz RC oscillator to an external 16MHz crystal should work flawlessly.  However, the value in the Clock Prescaler register will have different effects depending on the System Clock Source.  By default, the CLKPR register contains 0x00, regardless of clock source.  However, 0x00 will give a division factor of /2 when using the internal RC oscillator, while 0x00 will give a division facter of /1 for all other clock sources.  If the user wants to switch from the internal 16MHz RC oscillator to the external 16MHz crystal, the CLKPS3:0 bits must be changed accordingly within the CLKPR register from application code to ensure proper timing.  Note that the value written to the CLKPR register will override the CKDIV8 fuse.  See section 11.11.2 of the ATmega256RFR2 datasheet for full explaination and a table of division factors.

Objectives

  • Change the system clock source from the default 16MHz internal RC oscillator to the external 16MHz crystal that's loaded to the RFR2 Xplained Pro board.
  • The same Blinky_LED project will be used and the blink rate of the LED will be used to indicate changes in System Clock.

Requirements

  • One RFR2 Xplained Pro board with USB cable.
  • PC with Atmel Studio 6.1 installed

Procedure

  1. Download the following Blinky_LED project for Atmel Studio 6.1.
  2. Extract the contents of the downloaded folder and open the Blinky_LED project in Atmel Studio 6.1.
  3. Connect the ATmegaRFR2 Xplained Pro board to the PC using the USB cable
    • Tip

      Navigate to:  Control Panel  ->  Device Manager

      Verify "EDBG Virtual COM Port" shows up under Ports (COM & LPT)

  4. Verify that the device is running off the 16MHz internal RC oscillator at 1MHz:
    • In Atmel Studio, navigate to:  Tools  ->  Device Programming
    • In the "Tool" dropdown, select "XPRO-EDB".  Select "ATmega256RFR2" in the "Device" dropdown.  Select "JTAG" as the interface and click "Apply". 
      • Note

        Studio 6.1 should auto-detect if the Embedded Debugger has the most up-to-date firmware on it.  The user may be prompted to update firmware upon reading the device 
    • On the left side of the Device Programming dialog box, select "Fuses". 
    • Ensure that the CKDIV8 box is checked and the CKSEL_SUT option is "INTRCOS_6CK_65MS" (may have to scroll to view all fuses).  
    • Click "Program" and close the Device Programming dialog box.  The system should now be running off the internal RC oscillator at 1MHz if it wasn't already. 
    • Close the Device Programming dialog box.
  5. Save and build Blinky_LED in Atmel Studio 6.1.
  6. Program the RFR2 Xplained Pro board and verify the yellow on-board LED is toggling every half second.
  7. Now change the System Clock Source from the 16MHz internal RC oscillator to the 16MHz crystal that's loaded on the RFR2 Xplained Pro board.
    • In Atmel Studio, navigate to:  Tools  ->  Device Programming
    • Again, select "XPRO-EDB" as the Tool, "ATmega256RFR2" as the Device, and "JTAG" as the interface.  Click "Apply".
    • Select "Fuses" on the left.
    • In the CKSEL_SUT dropdown, select "TOSC_16KCK_65MS", and click "Program".
    • Close the Device Programming dialog box.
  8. Notice that the LED is blinking twice as fast as before.  This is because the value of 0x00 in the CLKPR register gave a /2 division factor when the internal RC oscillator was selected as the source.  With a different clock source now being used, the 0x00 value in the CLKPR register gives a division factor of /1.  This means the System Clock is now running at 2MHz instead of 1MHz (Note: the CKDIV8 fuse is still programmed).
  9. Adjust the System Clock back to 1MHz while still running off the external 16MHz crystal.
    • Add the following lines of code to the start of the main function in Blinky_LED.c:
    • Note

      Writing to the CLKPR register will override the CKDIV8 fuse.  If we simply changed the division factor from /1 to /2, the CKDIV8 fuse would have been overridden and the System Clock would have changed from 16MHz / 8 / 1  to  16MHz / 2.  Because of this, the CLKPR register must be written 0x04 to create a division factor of /16:  16MHz / 16 = 1MHz System Clock

  10. Save and compile Blinky_LED.

  11. Program the RFR2 Xplained Pro board and verify the LED toggles every half second as before.

The reader is encouraged to experiment with different clock sources and prescaler division factors to become familiar with the timing system


 

 ADC, UART, and I/O Daughter Card

ADC Background  

ATmega256RFR2 features a 10-bit successive approximation ADC with 8 possible single-ended channels and multiple differential channel options.  The user has the following options for reference voltage:

  • 1.5V Internal Reference Voltage
  • 1.6V Internal Reference Voltage
  • 1.8V Internal Reference Voltage
  • 1.5~1.8V External Reference Voltage

The analog signal on any of the ADC inputs should not exceed 1.8V.

USART Background

The ATmega256RFR2 has 2 USART's that can be run in full duplex, asynchronous or synchronous mode, with multiple frame options.

Objectives

  • Interface the I/O Xplained Pro Daughter Card with the RFR2 Xplained Pro board
  • Use the ambient light sensor on the I/O board as the input signal to the ADC.
  • Introduce a basic ADC example to the user
  • Convert ADC results into individual ASCII characters to be transmitted over UART
  • Introduce a UART example to the user (USART1 used in Asynchronous mode)
  • Use keyboard inputs to control program execution
  • Transmit ADC results over UART and display in terminal window on PC
  • 16MHz crystal is used as clock source for this tutorial to ensure accurate UART timing

Requirements

  • One RFR2 Xplained Pro board with USB cable
  • One I/O Xplained Pro Daughter Card
  • PC with 1 available USB port and hyper terminal program installed (Tera Term)
  • Atmel Studio 6.1 must be installed on PC
  • VCP driver must be installed on PC (This driver will become available to the PC once Studio 6.1 is installed)
  • Note

    Tera Term was used as the hyper terminal software for this tutorial.  However, any hyperterminal program that allows for serial communication can be used for this tutorial

    Download Tera Term for free

Procedure

  1. Download the following ADC_UART_Light_Sensor example project for Atmel Studio 6.1
  2. Extract the contents of the downloaded folder and open the ADC_UART_Light_Sensor project in Atmel Studio 6.1.
  3. Connect the I/O Xplained Pro Daughter Card to the EXT1 header on the RFR2 Xplained Pro board.
  4. Connect the ATmegaRFR2 Xplained Pro board to the PC using the USB cable. 
    • Tip

      Navigate to:  Control Panel  ->  Device Manager

      Verify "EDBG Virtual COM Port" shows up under Ports (COM & LPT) 

  5. Make sure 16MHz crystal is selected as System Clock source.
    • In Atmel Studio, in the menu bar, navigate to:  Tools  ->  Device Programming
    • In the "Tool" dropdown, select "XPRO-EDB".  Select "ATmega256RFR2" in the "Device" dropdown.  Select "JTAG" as the interface and click "Apply".
      • Note

        Studio 6.1 should auto-detect if the Embedded Debugger has the most up-to-date firmware on it.  The user may be prompted to update firmware upon reading the device 
    • On the left side of the Device Programming dialog box, select "Fuses".
    • In the CKSEL_SUT dropdown, select "TOSC_16KCK_65MS".
    • Click "Program" and close the Device Programming dialog box.  The system should now be running off the 16MHz crystal if it wasn't already.
    • Close the Device Programming dialog box.
  6. Open a Tera Term terminal window.
  7. Setup serial port parameters.
    • Within Tera Term, in the menu bar, navigate to:  Setup  ->  Serial Port
    • In the "Port" dropdown, select the enumerated port corresponding to the plugged in board.
      • Tip

        If you are unsure which port to select, unplug the board, reopen Serial Port, and see which port disappeared in the Port dropdown 
    • Select 38400 as the Baudrate
    • Select "8 bit" for data size
    • Select "none" for Parity
    • Select "1 bit" for Stop
    • Select "none" for Flow Control
    • Transmit delays should be zero
    • Click OK to save these settings
  8. Save and Build the ADC_UART_Light_Sensor in Atmel Studio 6.1
  9. Program the RFR2 Xplained Pro board
  10. Bring up the Tera Term terminal window.  Verify no characters have printed yet.
  11. On the RFR2 Xplained Pro board, verify that LED0 is on.
  12. Press SW0 on the RFR2 Xplained Pro board
    • Note

      The purpose of SW0 is to give the user time to bring up a terminal window and configure the serial port settings before the program actually prints any instructions.  Without some sort of "start" signal, the instructions would get transmitted over UART upon power-up and if the user didn't have the terminal window setup ahead of time, they would miss the Title header and instructions.

  13. The instruction header should display in the Tera Term window.
  14. Verify that LED0 is still on.
  15. Press <enter> on the keyboard.  The ADC voltage from the Light Sensor should display in mV.  Verify that the EDBG status LED continuously toggles indicating data is being transmitted over UART.
    • Tip

      If <enter> doesn't appear to trigger anything, make sure the terminal window is active by clicking somewhere in the terminal window.  Then try hitting <enter> again.

  16. Verify that the ADC voltage updates as the ambient light level changes.  As the light level gets darker, the voltage should get higher and vice versa.
    • Tip

      Use your hand to cover up the light sensor and make it darker.  If possible, shine a light on the light sensor to see how low you can make the voltage level

  17. Verify that LED0 has turned off.
  18. Press <esc> on the keyboard.  ADC conversions should cease and you should be prompted to press <enter> to resume.  LED0 should turn on indicating the device is waiting for a start signal.

The user is encouraged to examine each function within the ADC_UART_Light_Sensor project to become familiar with the various ADC and USART registers.  See if you can get different baud rates to work.  Challenge yourself to setup a receive FIFO buffer and setup some sort of command prompt instead of simple button presses to trigger different functions.

 


 Peer2Peer Wireless Communication using ALM

Objectives

  • Achieve wireless communication between two RFR2 Xplained Pro boards
  • Demonstrate unicast transmission
  • Create a sofware controlled LED pin
  • Create a miscellaneous timer that can be used by user application
  • Note

    In this tutorial, the miscellaneous timer is used to create an LED heartbeat, but in practice, the timer could be used for anything

Requirements

  • Two RFR2 Xplained Pro boards with USB cables
  • PC with 2 available USB ports and hyper terminal program downloaded (Tera Term)
  • Atmel Studio 6.1 must be installed on PC
  • VCP driver must be installed on PC (This driver will become available to the PC once Studio 6.1 is installed)
  • Note

    Tera Term was used as the hyper terminal software for this tutorial.  However, any hyperterminal program that allows for serial communication can be used for this tutorial

    Download Tera Term for free

Procedure

  1. Download Atmel Lightweight Mesh
    • Tip

      Once the ALM folder is downloaded, make another copy for editing and keep the original unchanged. If you ever need to start from scratch, you won't need to re-download the entire ALM.  Just make a new copy of the saved original 
  2. Within the ALM download folder, navigate to:  LwMesh_1_0_1  ->  apps  ->  Peer2Peer  ->  astudio
  3. Open the XplainedPRO_ATmega256rfr2 project in Atmel Studio 6.1.
  4. Connect the first RFR2 board to an open USB port of the PC using a USB cable.
    • Tip

      Navigate to:  Control Panel  ->  Device Manager

      Verify "EDBG Virtual COM Port" shows up under Ports (COM & LPT)

  5. Make system clock 8MHz.  The RFR2 Xplained Pro board ships with the internal oscillator selected as the system clock source and the CKDIV8 fuse programmed.  This means the default system clock will be 1MHz.  For the ALM timing to be accurate, the user must change the system clock to 8MHz. 
    • Within Studio 6.1, in the menu bar, navigate to:  Tools  ->  Device Programming
    • In the "Tool" dropdown, select "XPRO-EDB".  Select "ATmega256RFR2" in the "Device" dropdown.  Select "JTAG" as the interface and click "Apply". 
    • Studio 6.1 should auto-detect if the Embedded Debugger has the most up-to-date firmware on it.  The user may be prompted to update firmware upon reading the device

    • On the left side of the Device Programming dialog box, select "Fuses".  Ensure that the CKDIV8 box is unchecked and the CKSEL_SUT option is "INTRCOS_6CK_65MS".  
    • Click "Program" and close the Device Programming dialog box.  The system should now be running off the internal RC oscillator at 8MHz. 
    • Close the Device Programming dialog box.
  6. Select Embedded Debugger as the debugger/programmer
    • Within Studio 6.1, in the menu bar, navigate to:  Project  ->  XplainedPRO_ATmega256rfr2 Properties
    • On the left side of the properties window, select "Tool"
    • In the "Selected debugger/programmer" dropdown, select "XPRO-EDBG".
    • Select "JTAG" as the interface
    • Use the slide bar to set the JTAG clock to 200kHz or less.
    • Save and close the Properties tab.
  7. Create a software controlled LED pin within the ALM stack.
    • In the XplainedPRO_ATmega256rfr2 project, in the Solution Explorer Window, navigate to:  stack  ->  hal  ->  atmega256rfr2  ->  inc  ->  hal.h
    • In hal.h, add the following block of code:
    • In the Solution Explorer Window, navigate to:  stack  ->  hal  ->  atmega256rfr2  ->  src  ->  hal.c
    • In hal.c, add the following block of code to the HAL_Init() function:
  8. Create a miscellaneous timer

    • In the Solution Explorer Window, open Peer2Peer.c.

    • Add the following variable declaration towards the top of the file:
    • Within Peer2Peer.c, add the following block of code at the end of the appInit() function to configure a 1 second timer:
    • Within Peer2Peer.c, add the following function to execute the heartbeat timer.

    • Note

      This function must be placed above the appInit() function

9.   Echo typed characters in host terminal:

    • Within Peer2Peer.c, add the following line of code to the HAL_UartBytesReceived() function, after the HAL_UartReadByte() function call:

10.   Enable acknowledge signals between the two boards:

    • Within Peer2Peer.c, in the appSendData() function, modify the options line to the following:

11.   Verify Device Configuration

    • Within the Solution Explorer Window, open config.h.
    • Verify the following constant values are defined:
    •  Note:  The default values are kept for the first device.

12.   Save and Build the project.

13.   Program the first board.  Verify that the yellow LED toggles every second.

14.   Setup terminal window.

    • Open Tera Term window
    • In menu bar, navigate to:  Setup  ->  Serial Port
    • In the "Port" dropdown, select the enumerated port corresponding to the plugged in board. 
      • Tip

        If you are unsure which port to select, unplug the board, reopen Serial Port, and see which port disappeared in the Port dropdown

    • Select 38400 as the Baudrate
    • Select "8 bit" for data size
    • Select "none" for Parity
    • Select "1 bit" for Stop
    • Select "none" for Flow Control
    • Transmit delays should be zero
    • Click OK to save these settings

         Begin typing characters on the keyboard.  They should appear in the Tera Term window as they are typed.

15.   Configure 2nd board.

    • In Atmel Studio 6.1, in the same XplainedPRO_ATmega256rfr2 project, open config.h if it's not already opened.
    • Change the APP_ADDR constant to '1' as shown below:
    • All other constants should be left alone for this tutorial.

16.   Save and build the project.

17.   Connect the second board to the PC.  If this is the first time connecting this board, ensure the drivers install correctly in Device Manager. 

18.   Ensure the system clock is set to 8MHz as shown in Step 5.

19.   Change the debugger/programmer to the EDBG of the 2nd board.

    • In Atmel Studio, in the menu bar, navigate to:  Project  ->  XplainedPRO_ATmega256rfr2 Properties
    • On the left side of the Properties window, select "Tool"
    • In the "Selected debugger/programmer" dropdown, select the 2nd RFR2 Xplained Pro board.
    • Select "JTAG" as the interface
    • Make sure the JTAG Clock is 200kHz or less
    • Save and close the project properties tab

20.   Program 2nd board.  Verify the LED toggles every second.

21.   Configure 2nd terminal window.

    • Open a second Tera Term window.
    • Configure the serial port as shown in Step 13.

22.   Begin typing characters in the 2nd Tera Term window.  If both boards are powered up and within range of each other, characters should appear in both Tera Term windows.  If not, try resetting the boards.


 

 Multi-Node Wireless Communication using ALM

Atmel's Lightweight Mesh (ALM) is a proprietary wireless network protocol that is free to download and use.  If ZigBee compliance is not necessary for your project, ALM can offer a simple mesh network solution.  ALM still offers basic services such as automatic routing, acknowledge signals, basic security, energy detection, RSSI, as well as broadcast, multicast, and uni-cast transmission types.  You can also access some simple hardware functions like timers, GPIO, and sleep mode.  ALM uses much less flash than a ZigBee stack such as BitCloud.  This is because it doesn't offer advanced features like network commissioning, automatic node addressing, automatic transmission retry, and advanced security.  ALM v1.2.1 was used for this tutorial.

Project Overview

A 3 node network was implemented for this tutorial.  NODE0 is considered the central node that receives user commands from a PC.  NODE1 and NODE2 are considered remote nodes that receive commands from NODE0.  A simple command prompt was setup to control LED behavior for every node in the network.  The command prompt accepts the following custom AT commands:

  • "ATLC<enter>"  -  Turn on the LED on the local node.  The LED is active low (Local Clear).
  • "ATLS<enter>"  -  Turn off the LED on the local node (Local Set).
  • "ATRC[n]<enter>"  -  Turn on the LED on remote node n (Remote Clear).  Example:  Turn on LED of remote node 1:  "ATRC1<enter>"
  • "ATRS[n]<enter>"  -  Turn off the LED on remote node n (Remote Set). 
  • "ATRR[n]<enter>"  -  Read current state of LED pin on remote node n (Remote Read).
  • "ATBC<enter>"  -  Turn on the LED on all remote nodes (Broadcast Clear).
  • "ATBS<enter>"  -  Turn off the LED on all remote nodes (Broadcast Set).

The UART was setup with the following serial communication settings:

  • Baud: 38400 bps
  • Data: 8-bit
  • Parity: none
  • Stop bits: 1
  • Flow Control: none

For this application, acknowledge signals were enabled.  Therefore, remote nodes submit an acknowledge signal whenever a uni-cast message is received from NODE0.  Acknowledge signals are not issued in response to broadcast messages.  ALM doesn't automatically resubmit messages if no Acknowledge signal is received.  It is up to the designer to accomplish this in application code.  For this project, if expected Ack was not received, NODE0 will retransmit the message up to 5 times before dropping the transaction and displaying an error message.

I didn't set up any commands for configuring network parameters like PAN ID, frequency channel, or a security key.  These can all be defined in config.h.

The ALM also supports up to 16 application endpoints for each node.  This means you can route a message not only to a specific node in the network, but a specific endpoint within a specific node.  This application only uses a single endpoint, but you can very easily add code to support additional endpoints.  See the Atmel Lightweight Mesh Developer Guide for details.

As is, the ALM only supports Power Save sleep mode with Timer2 used as a periodic wake-up source (using 32kHz crystal).  The user can add other wake-up sources as desired.  Because of the nature of this application, sleep mode was not implemented on remote nodes.  The WSNDemo application within the ALM download folder is a great example project that demonstrates a variety of ALM features.  It demonstrates sleep mode on remote nodes, RSSI, random number generation, and 2-way communication between various nodes.

Objectives

  • Setup a multi-node network for wireless data transfer

  • Setup a command prompt to accept commands from user
  • Demonstrate how to use Acknowledge signals and transmission retries
  • Demonstrate unicast transmission
  • Demonstrate broadcast transmission
  • Demonstrate 2-way communication (unicast with response)

Requirements

  • Three or more RFR2 Xplained Pro boards with USB cables
  • PC with hyper terminal program downloaded (Tera Term) and USB port for each node
  • Atmel Studio 6.1 or later must be installed on PC
  • VCP driver must be installed on PC (This driver will become available to the PC once Studio 6.1 is installed)
  • Note

    Tera Term was used as the hyper terminal software for this tutorial.  However, any hyperterminal program that allows for serial communication can be used for this tutorial

    Download Tera Term for free

Procedure

  1. Download the following example application.  It was written using the "template" application from Atmel Lightweight Mesh (ALM) v1.2.1.
  2. Open the project in Atmel Studio 6.1.
  3. Connect the first RFR2 board to an open USB port of the PC using a USB cable.
    • Tip

      Navigate to:  Control Panel  ->  Device Manager

      Verify "EDBG Virtual COM Port" shows up under Ports (COM & LPT)

  4. Make system clock 8MHz.  The RFR2 Xplained Pro board ships with the internal oscillator selected as the system clock source and the CKDIV8 fuse programmed.  This means the default system clock will be 1MHz.  For the ALM timing to be accurate, the user must change the system clock to 8MHz. 
    • Within Studio 6.1, in the menu bar, navigate to:  Tools  ->  Device Programming
    • In the "Tool" dropdown, select "XPRO-EDB".  Select "ATmega256RFR2" in the "Device" dropdown.  Select "JTAG" as the interface and click "Apply". 
    • Studio 6.1 should auto-detect if the Embedded Debugger has the most up-to-date firmware on it.  The user may be prompted to update firmware upon reading the device

    • On the left side of the Device Programming dialog box, select "Fuses".  Ensure that the CKDIV8 box is unchecked and the CKSEL_SUT option is "INTRCOS_6CK_65MS".  
    • Click "Program" and close the Device Programming dialog box.  The system should now be running off the internal RC oscillator at 8MHz.
  5. Setup a terminal window:
    • Open Tera Term
    • Navigate to:  Setup  ->  Serial Port
    • Select the COM port for the first board
    • Select 38400 baud, 8-bit data, no parity, 1 stop bit, no flow control
    • Click OK
  6. Select Embedded Debugger as the external debugger/programmer
    • Within Studio 6.1, in the menu bar, navigate to:  Project  -> <project name> Properties
    • On the left side of the properties window, select "Tool"
    • In the "Selected debugger/programmer" dropdown, select "XPRO-EDBG".
    • Select "JTAG" as the interface
    • Use the slide bar to set the JTAG clock to 200kHz.
    • Save and close the Properties tab.
  7. Save and build the project.
  8. Program the board.  You can start a debug session or select  Debug  ->  Start Without Debugging.  If for some reason it doesn't seem to be programming, go to Tools  ->  Device Programming.  Select "XPRO-EDBG" as the Tool, "ATmega256RFR2" as the Device, and JTAG as interface and click Apply.  Select the "Memories" tab.  In the "Flash" section, browse to the hex file you just compiled.  It should be in the debug folder of your project directory.  Make sure the "Erase" and "Verify" boxes are checked and click program.
  9. You should see a header string print in the terminal window.  If you press <enter> you should see a command prompt appear ">>".
  10. Type "ATLC" and press <enter>.  You should see the yellow user LED turn on.  You should also see a '00' response.  That is just a simple 'OK' message indicating success.
  11. Type "ATLS" and press <enter>.  You should see the yellow user LED turn off.
  12. Connect the second board to the PC.
  13. Configure the core clock as described in step 4.
  14. In Atmel Studio, within the Solution Explorer window, open config.h
  15. Change the APP_ADDR from 0 to 1.  All other definitions can be left alone.
  16. Save and build the project.
  17. Program the second board.  The yellow status LED will toggle when programming.  Make sure you aren't programming the wrong board!
  18. Connect the third board to the PC.
  19. Configure the core clock as described in step 4.
  20. In Atmel Studio, within the Solution Explorer window, open config.h
  21. Change the APP_ADDR from 1 to 2.  All other definitions can be left alone.
  22. Save and build the project.
  23. Program the third board.  The yellow status LED will toggle when programming.  Make sure you aren't programming the wrong board!
  24. Continue this process until all your nodes are programmed.  This application only supports 15 remote nodes (addresses 1-15 or 0x1-0xf).  This is due to the way I wrote the application, NOT a limitation of ALM.  The ALM theoretically supports up to 65,535 nodes in a single network.
  25. Go back to the terminal window and type "ATBC" and press <enter>.  You should see the yellow user LEDs on all remote nodes turn on.  Acknowledge signals are not sent with broadcast messages, but you should also see a '00' response indicating the data was sent.
  26. Type "ATBS" and press <enter>.  You should see all the remote LEDs turn off and the '00' response.
  27. Type "ATRC1" and press <enter>.  On remote node 1, you should see the LED turn on.  The application will expect an acknowledge signal from Node 1.  If it doesn't receive one, it will retry up to 5 times.  It will print a '00' response when an ACK is received or an error message if it never receives an ACK signal.
  28. Type "ATRR1" and press <enter>.  You should get a '00' response when an ACK is received.  You then should see a string printed indicating the current state of the LED pin on remote Node 1.  Since you previously sent a command to turn it on, the LED pin should read '00' (active low LED).
  29. Type "ATRS1" and press <enter>.  The LED on remote Node 1 should turn off.  You should either get a '00' success response, or an error message after 5 transmission attempts with no ACK signal received.
  30. Use the "ATRR1" command to check the state of the LED pin.  It should now read '01' for 'OFF'.
  31. Try these commands for all of the remote nodes in your network.  

Below is a screenshot of the terminal window while running this application along with some notes (notes are in red text).  You can see the AT commands entered from the keyboard along with responses from remote nodes. 

As you can see, the wireless link between NODE0 and NODE2 was not very good.  Transmission may fail due to physical obstacles.  Try maintaining line of sight if you are having trouble communicating.  If that's not an option or it doesn't work, you can try increasing the transmit power or using a different frequency channel.

Some Additional Things to Think About

In this application, everything starts and ends with NODE0.  However, there is nothing stopping you from setting up a command prompt on multiple nodes.  There is no parent-child relationship in ALM.  There are also no dedicated Coordinators, Routers, or End Devices.  Each node is on the same hierarchy by default.  It is up to the designer to establish hierarchy within application code if desired.

This application was written to accept custom AT commands because that is a widely implemented method for wireless MCU applications.  These commands will not work on other devices.  They are custom commands written specifically for this example.  You can very easily add your own commands to this example.

This is a pretty simple example of remote GPIO control within a multi-node network.  Once you achieve control over remote GPIO, you should very easily be able to control any peripheral on a remote device (ADC, UART, SPI, I2C, PWM, Timers, etc).

For this example, I started with the "Template" application included in the ALM v1.2.1 download.  Once you feel comfortable with this example and the Peer2Peer example above, I encourage you to start with a blank Template project and write your own application from scratch.  It is a tremendous learning experience and can introduce a variety of new concepts to you.


 

Additional Info / Known Issues

  • The Xplained Pro series of development kits all use a USB micro-B connector for power and programming interface.  A USB cable comes with the ATmega256RFR2 Xplained Pro Starter Kit, but does not ship with the ATmega256RFR2 Xplained Pro Evaluation Kit.  Here's a link to a USB cable that will work for the eval kit.
  • Atmel Studio 6.1 or later must be used for this development kit.  Prior versions of Atmel Studio do not support the EDBG interface.  Also, the EDBG drivers will not install properly without Atmel Studio 6.1 installed.  Here's a link to a free download of Atmel Studio 6.1
  • In the ATmega256RFR2 device, the value within the Clock Prescaler register will have different effects depending on the System Clock Source. 
    • By default, the CLKPR register will read 0x00, regardless of clock source.  However, 0x00 will give a division factor of /2 when using the internal RC oscillator, while 0x00 will give a division facter of /1 for all other clock sources.  
    • The RFR2 Xplained Pro board ships with the ATmega256RFR2 running off its internal 16MHz RC oscillator and the CKDIV8 fuse is programmed by default.  Since the internal 16MHz RC oscillator is the source, the system clock will be:   16MHz / 2 / 8 = 1MHz;   
    • The built-in 1:2 prescaler that comes with the 16Mz internal RC allows for backward compatibility with software meant for older mega devices running off an 8MHz internal RC. 
    • If the user wants to change the clock source from the internal 16MHz RC oscillator to the board-mounted 16MHz crystal, leaving the CLKPR register at its default value will change the system clock from 1MHz to 2MHz because the CLKPR division factor will be /1 instead of /2.  This isn't a problem so much as an inconvenience.  If the user switches from the internal 16MHz RC oscillator to the external 16MHz crystal, the CLKPS3:0 bits must be changed accordingly within the CLKPR register from application code to ensure proper timing.  
    • See section 11.11.2 of the ATmega256RFR2 datasheet for full explaination and a table of division factors.
  • The OLED daughter card is intended to be connected to EXT3 on the Xplained Pro boards.  The 3 LEDs on the OLED daughter card are not excessible to the MCU if connected to EXT3 of the RFR2 Xplained Pro board.  The OLED that's loaded on the OLED daughter card can be controlled using the ATmega256RFR2 board.  However, the OLED datasheet and the OLED controller datasheet are not excessible to the public.  The user must submit a request to the respective manufacturer for device datasheets.

Contact the Author

The reader is strongly encouraged to read through all of the documents referenced on this page.  I encourage you to sift through the various datasheets, as well as the ALM stack in Atmel Studio and try and implement available functionality that is not covered in any of these tutorials.  This page is not meant to give you all of the answers for wireless network implementation.  It is a starting point, meant to give you some basic examples that you can build on and apply in more complex applications.  If you have any interesting breakthroughs, I'd love to hear about them.  If you have questions, feedback, or a topic you would like to see added to the eewiki, let me know at eewiki@digikey.com.  I hope you enjoy experimenting with Atmel's RF products and the Xplained Pro eval boards!

   -  Scott

 

  • No labels