piconomix-fwlib  0.7.1
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers
3.2 Piconomix ATmega328P Scorpion Board

1. Introduction

A Microchip ATmega328P development board.

piconomix_scorpion_board.jpg
Piconomix ATmega328P Scorpion Board

There is:

2. Hardware Features

  • Microchip ATmega328P microcontroller with 32 kB FLASH and 2kB SRAM
  • 7.3728 MHz crystal for precise UART BAUD rates
  • Shipped with 1kB XMODEM-CRC Bootloader and CLI Explorer (Command Line Interpreter)
  • Genuine FTDI FT230XS USB-UART Bridge for bootloader, serial communication and +5V supply.
  • User Interface:
    • User LED, UART RX and TX LED
    • User button
    • Reset button
    • Piezo buzzer
      - Adesto AT45DB041E 512 kB (with extra 16 kB) DataFlash with SPI interface
  • Ultra low-power Microchip MCP1700T-3302E/MB linear regulator for outstanding battery life (in sleep mode)
  • 100 mil (2.54 mm) pitch header:
    • 5 x GPIO (General Purpose Input / Output pins)
    • 4 x A/D (Analog to Digital Channels with scaling and filtering)
    • 1 x UART (Shared with USB-UART bridge; selectable with PX_UART_SEL GPIO pin)
    • 1 x SPI (Serial Peripheral Interface)
    • 1 x I2C with 4.7k pull-up resistors (Philips / NXP Inter-Integrated Circuit bus)
    • PWR (External +3.6V to +6V power supply)
  • Standard 2x3 ISP/DBG header (In System Programming / Debugging)
  • 2 x 3.4 mm mounting holes; ideal for M3 threaded hexagonal spacers

3. Design Documents and Files

4. Disclaimer

This development/evaluation tool is suitable for research and development in
a controlled laboratory environment and not designed or tested as a finished
appliance for end users. Precautions must be taken against improper use such
as Electrostatic Discharge (ESD) damage, over-voltage / over-current 
electrical stress, incorrect power sequencing, etc.

THE HARDWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS HARDWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

5. Reference documents

6. Board Support Package

A Board Support Package (px_board.h : Piconomix ATmega328P Scorpion Board) is provided that:

  • define the CPU frequency
  • define the GPIO pins
  • define macros to manipulate GPIO functions
  • provide a function to initialise the board
  • provide functions for the SPI driver to manipulate SPI chip select pins
  • provide a delay functions

Files:

7. Getting started

The following free software tools are needed:

Atmel Studio 7 does includes GNU utilities like make, rm and cp (from the CoreUtils package) but lacks sh that is required for advanced Makefiles.

7.1 Install USB-UART Bridge Virtual Com Port (VCP) USB driver

If you already have the latest driver installed, then these steps can be skipped.

7.1.1 Remove old FTDI Virtual Com Port (VCP) driver

Download and run the CDM Uninstaller:

cdm_uninstaller.png

7.1.2 Add registry setting to ignore FTDI device serial number

Normally each FTDI device (identified by it's unique serial number descriptor) is assigned a different COM port number.

FTDI Ignore Hardware Serial Number Registry Editor Utility updates the registry so that any FTDI device connected to the same USB port is assigned the same COM port number. The registry setting must be applied before the USB device driver is installed for the connected FTDI device. This explains why step 7.1.1 is done first

Specify the device type and VID/PID and press WRITE to apply. You can also remove the registry setting with the ERASE button.

ftdi_ignore_ser.png

The utility should be run before the first device installation.

7.1.3 Install new driver

Download and install the FTDI FT230XS USB-UART Bridge Virtual Com Port (VCP) driver.

7.2 Connect board to PC with Mini-B USB Cable

+5V will be supplied to the board via USB and the microcontroller will start executing code. The firmware shipped with the board enables the user LED and this fact can be used to verify that the board is powered.

The operating system will detect if a new USB device has been plugged in and install the correct driver for it. Take note which COM port has been assigned. The Device Manager utility can also be used to find out:

Start > Device Manager

device_manager.png
Windows Device Manager - COM port assignment

7.3 Install Tera Term - Terminal Emulator

Download and install Tera Term - Terminal Emulator.

7.3.1 Run and configure Tera Term - Terminal Emulator

Select correct COM port and configure port for 115200 BAUD, 8 data bits, no parity, 1 stop bit and no flow control:

Setup > Serial port...

tera_term_setup.png
Tera Term COM port setup

7.3.2 Press RST (reset) button

The microcontroller will reset and start executing the XMODEM-CRC Bootloader. The bootloader will send a 'C' character to initiate the XMODEM-CRC upload process. After 1 second it will time out and jump to the application. The CLI application will start, clear the Tera Term display and show the start up "splash screen" with a prompt ">" to show that it is ready to accept a new command.

7.3.3 Type 'help' and ENTER

This command will list all of the available commands with parameters:

tera_term_cli.png
CLI Demo on Tera Term (Terminal Emulator)

7.3.4 Type 'beep 100' and ENTER

This command will drive the piezo buzzer for 100 ms at a frequency of 4 kHz.

Simply put, the buzzer will give a short beep.

7.4 Install Atmel Studio 7

Download and install Atmel Studio 7.

7.5 Install UnixShellUtils

Download UnixShellUtils and extract downloaded package to root of drive, e.g.

C:\UnixShellUtils

7.6 Set up Atmel Studio to use custom build tools (UnixShellUtils)

Start Atmel Studio. Configure options:

Tools > Options... > Builder > GNU Make

as_options_menu.png
Atmel Studio - Options

Set the path to the custom shell utils and make:

as_builder_custom.png
Atmel Studio - Custom ShellUtils

If you want to correctly build other projects generated with the Atmel Studio Framework, you have to return this setting back from Custom to Default. Atmel Studio will remember the custom settings, so it is quick to switch between Custom and Default.

7.7 Build example in Atmel Studio

All of the tutorials and examples are provided with pre-configured Atmel Studio projects. External Makefiles are referenced, instead of using Atmel Studio's build system, to make the projects cross-platform.

Open and build Minimal GPIO Example. It is located here:

piconomix-fwlib/boards/avr/piconomix_scorpion_board/examples/01_gpio/gpio.atsln

File > Open > Project/Solution... Ctrl+Shift+O

as_open_project_menu.png
Atmel Studio Open Project menu

Navigate to the project, select and open:

scorpion_board_open_project.png
Atmel Studio Open Project selection

Build the project:

Build > build Solution F7

scorpion_board_build_project.png
Build solution in Atmel Studio

If this step was not succesfull, it probably means that the custom build tools was not correctly set up. Go back to 7.6 Set up Atmel Studio to use custom build tools (UnixShellUtils)

7.8 Upload example to Scorpion Board

After building Minimal GPIO Example succesfully, you will have a binary file called "gpio.bin". The new application is sent to the XMODEM-CRC Bootloader via Tera Term:

File > Transfer > XMODEM > Send...

tera_term_xmodem_send01.png
Tera Term - Start XMODEM file send

The BIN file (not HEX or ELF!) is selected and the CRC variant of XMODEM is specified:

tera_term_xmodem_send02.png
Tera Term - Select file and specify CRC transfer method

Tera Term will now wait for the XMODEM-CRC Bootloader to initiate the transfer by sending a 'C' character...

Press the reset button (RST) to reset the microcontroller and jump to the bootloader.

The bootloader will now initiate the transfer and download the new application. At the end of the transfer, the bootloader will execute the new application. Note that no safeguards are built into the bootloader. If the transfer is interrupted, the bootloader will time out and execute the broken, incomplete application. Normally this is not a big issue as the process can just be restarted.

Press the user button. The user LED will turn on while the button is being pressed and turn off when the button is released. Success!

8. AVR quick start guide

You now have a working development environment and I really hope it was quick and straight forward to set up. You should be able to compile an application in the IDE and upload it using the bootloader.

To make sure, build and upload CLI Explorer (Command Line Interpreter)

The next step is to learn how to write C programs for the AVR architecture. A quick start guide with tutorials and examples have been created as an introduction. Click HERE to proceed to the AVR quick start guide.

9. Arduino development on Scorpion Board

You can also use the Arduino environment to develop code for the Scorpion Board. Click HERE to proceed to Arduino development on the Scorpion Board.