AVR XMEGA uC/OS Ports

AVR XMEGA-A1 Xplain and Xplained: The Difference Explained

"The Atmel XMEGA-A1 Xplained kit, revision 7, is the first released revision of the XMEGA-A1 Xplained kit. This kit replaces the Atmel Xplain evaluation kit. Information about the original Xplain evaluation kit can be found in application note AVR1907". [from Atmel document AVR1924 available here]

It appears Atmel has modified the original Xplain board and renamed it to Xplained to ensure compatibility with other Xplained-branded add-on boards such as Sensors Xplained, Temperature Sensors Xplained and CryptoAuthentication Xplained. For more information go to the Xplained product page here.

 
AVR XMEGA-A1 Xplain Rev.4

 
AVR XMEGA-A1 Xplained Rev.7

 

uC/OS-II

Quite some time ago, Micrium released a port of their popular real-time operating system, uC/OS-II, for the AVR XMEGA microcontroller (see here). However, this port was designed specifically for the STK600 - a development system produced by Atmel which can be considered quite expensive in comparison to other boards that can be used to evaluate the XMEGA (such as the XMEGA-A1 Xplain and the newer XMEGA-A1 Xplained - both shown above). This prompted me to modify Micrium's original port so that it could be used on both the Xplain and Xplained evaluation boards and then also be easily adapted to any project/product based on the XMEGA.

 

Evaluating and Testing uC/OS-II 

 

Required tools/software:

  • AVR XMEGA-A1 Xplain or Xplained evaluation board
  • Terminal program (such as Br@y's Terminal)
  • USB A to Mini B cable (for board power and communication)
  • USB to TTL serial cable (such as the FTDI3BLACK by AvitResearch) [Optional - required if not using the USART-to-COM port bridge]
  • AVR programming tool (such as the AVRISP mkII or AVR JTAGICE mkII)


Procedure:
  1. Use a USB A to Mini B cable to power the board. This cable also provides access to USARTC0 via a PC COM port.
  2. Download the project archive for your evaluation board [see Downloads section at bottom of page] and flash the HEX file to the XMEGA using an AVR programming tool.
  3. Open up the COM port corresponding to the USART-to-COM port bridge (9600 baud, 8 data bits, no parity, 1 stop bit) - if successful, the uC/OS CPU Usage will be printed every second to the terminal.
  4. Test that any data sent to the XMEGA board is echoed back to terminal. Also test/observe the following:
Push-buttons:
  • SW0: Prints the CPU USAGE variable to USARTC0.
  • SW1: Prints the clock speed (F_CPU) to USARTC0.
  • SW2: Prints the uC/OS-II version (OS_VERSION) and the interrupt enable/disable method (OS_CRITICAL_METHOD) to USARTC0.
  • SW3: Prints the tick rate (OS_TICKS_PER_SEC) and the USARTC0 RX ring buffer size (in bytes) (RX_BUFFER_SIZE_USARTC0) to USARTC0.
  • SW4: Prints the number of tasks (APP_CFG_N_TASKS) to USARTC0.
  • SW5: Prints the Start Task stack size (in bytes) (APP_CFG_TASK_START_STK_SIZE) to USARTC0.
  • SW6: Prints the task stack size (in bytes) (APP_CFG_TASK_START_STK_SIZE) to USARTC0.
  • SW7: Toggles ON/OFF the printing of the CPU USAGE variable to USARTC0 every 1000ms.

LEDs:
  • LED0: Toggles when the Idle Task is run - see app_hooks.c for more details.
  • LED1: Toggles when the Statistics Task is run - see app_hooks.c for more details.
  • LED2: Toggles when a task switch is performed - see app_hooks.c for more details.
  • LED3: Toggles each timer tick - see app_hooks.c and os_cfg.h for more details.
  • LED4: Toggles when Task 2 is run (every 250ms).
  • LED5: Toggles when Task 3 is run (every 500ms).
  • LED6: Toggles when Task 4 is run (every 1000ms).
  • LED7: Toggles when pushbutton_timer_isr_handler() is invoked (every 20ms).

 
Terminal application connected to the AVR XMEGA-A1 Xplain running uC/OS-II v2.92.01

 

uC/OS-III

 

Evaluating and Testing uC/OS-III 

 

Required tools/software:

  • AVR XMEGA-A1 Xplain or Xplained evaluation board
  • Terminal program (such as Br@y's Terminal)
  • USB A to Mini B cable (for board power and communication)
  • USB to TTL serial cable (such as the FTDI3BLACK by AvitResearch) [Optional - required if not using the USART-to-COM port bridge]
  • AVR programmer (such as the AVRISP mkII or AVR JTAGICE mkII)

Procedure:
  1. Use a USB A to Mini B cable to power the board. This cable also provides access to USARTC0 via a PC COM port.
  2. Download the project archive for your evaluation board [see Downloads section at bottom of page] and flash the HEX file to the XMEGA using an AVR programming tool.
  3. Open up the COM port corresponding to the USART-to-COM port bridge (9600 baud, 8 data bits, no parity, 1 stop bit) - if successful, the uC/OS CPU Usage will be printed every second to the terminal.
  4. Test that any data sent to the XMEGA board is echoed back to terminal. Also test/observe the following:
Push-buttons:
  • SW0: Prints the OSStatTaskCPUUsage variable to USARTC0.
  • SW1: Prints the clock speed (F_CPU) to USARTC0.
  • SW2: Prints the uC/OS-III version (OS_VERSION) and the interrupt enable/disable method (CPU_CFG_CRITICAL_METHOD) to USARTC0.
  • SW3: Prints the tick rate (OS_CFG_TICK_RATE_HZ) and the USARTC0 RX ring buffer size (in bytes) (USARTC0_RX_BUFFER_SIZE_BYTES) to USARTC0.
  • SW4: Prints "Push-Button 4 press detected." to USARTC0.
  • SW5: Prints "Push-Button 5 press detected." to USARTC0.
  • SW6: Prints "Push-Button 6 press detected." to USARTC0.
  • SW7: Toggles ON/OFF the printing of the CPU USAGE variable to USARTC0 every 1000ms.

LEDs:
  • LED0: Toggles when the Idle Task is run. See os_app_hooks.c for more details.
  • LED1: Toggles when the Statistics Task is run. See os_app_hooks.c for more details.
  • LED2: Toggles when a task switch is performed. See os_app_hooks.c for more details.
  • LED3: Toggles each timer tick. See os_app_hooks.c and os_cfg_app.h for more details.
  • LED4: Toggles when Task 2 is run (every 250ms).
  • LED5: Toggles when Task 3 is run (every 500ms).
  • LED6: Toggles when Task 4 is run (every 1000ms).
  • LED7: Toggles when pushbutton_timer_isr_handler() is invoked (every 20ms).

Terminal application connected to the AVR XMEGA-A1 Xplain running uC/OS-III v3.03.00

 

Downloads

Note: uC/OS-II and uC/OS-III are not open-source. Please read the licensing terms here.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The complete Atmel Studio 6 projects are available on GitHub. Pre-compiled HEX files are also provided if you simply wish to evaluate uC/OS on the XMEGA without having to build/modify the source.

uC/OS-II: https://github.com/nickdademo/xmega-ucos-ii
uC/OS-III: https://github.com/nickdademo/xmega-ucos-iii