www.eXtremeElectronics.co.in

Development Process.

xBoard v2.0

Easy to Use learning and development tool for Atmel AVR family of MCUs.

 

<< Return To Help Index

The development process with AVR/xBoard is outlined below.

  1. First you should know what you are trying to make. You should have some algorithm in your mind and some clue on how the program should look. Or else you may have a ready made program, for example from a Website or Magazine. The human readable code is written in some high level Language like C,C++, BASIC etc. This code is called Source Code. We will use C language through out these tutorials.
  2. You need a Text Editor to enter the Source Code and save in a computer file, so that these can be processed by computer software.
  3. Then a Compiler, which is a software that input a Source code in a syntax of some programming language (in our case C) and generates a machine instructions for a specific machine(AVR MCU in our case). In Microcontroller world these file are called HEX files(the extension is .HEX , eg. myprogram.hex)
  4. After this we load this HEX file in a programmer software. We connect our programmer with PC and then Connect the programmer with xBoard. The programmer software then uploads this file to the board, after that the board will execute our program.
ISP Programmer used To Upload a HEX file.

 

isp header on xboard
ISP Headers on xBoard v2.0

 

ISP Programmer used To Upload a HEX file.

 

Software Tools

The main software you will need are:

 

You can get all the software from the folder named "Software" in the Support Disc. It is better to install WinAVR in root of a drive like c:\winavr or d:\winavr. Also please install WinAVR first then AVR Studio, this will let AVR Studio detect the compiler. Now you are ready to write you first microcontroller program !!! In this tutorial, you will learn the basic steps required for any microcontrollers based project. We will write a basic “hello world” project, which is a simple LED blinker.

Step I Entering and compiling code.

Start “AVR Studio” from Start Menu->All programs->Atmel AVR Tools-> AVR Studio 4 You will be presented with a Project wizard as shown below.

AVR Studio Project Wizard

Fig - AVR Studio Project Wizard

Project Delails

Fig - Project Details

 
Select AVR GCC in Project type then enter a suitable project name say “hello” and select a location in you hard disk. Then click next. Make sure that “Create initial file” and “Create folder” option is checked.

Device Selection

Fig - Device Selection

 
In this dialog box select AVR Simulator in “Debug Platform” list and select the AVR MCU depending on the type of MCU installed on your development board, in Device list. Click finish. After that you will be presented with an Integrated Development Environment-IDE. As shown below.

AVR Studio main window

Fig - AVR Studio main window

 
This IDE will help you in editing, modifying, and compiling source program. After a project is compiled it gives you a “.hex” file ready to burn to your MCU. The main parts of the window are Now copy past or type the following code in the code editor.

/*********************************************************************

                 xBoard2 Sample Programs
               ---------------------------


Description :  Simple program to blink led on PORTD7.
            
            
            NOTE: PLEASE SHORT JUMPER J1 (THIS WILL CONNECT LED WITH PD7)

            If you don't get the Tricks of Logical Operators
            (like & and |) please see

http://extremeelectronics.co.in/avr-tutorials/programming-in-c-tips-for-embedded-development/

            For Getting Started with AVR MCUs see

            http://extremeelectronics.co.in/category/avr-tutorials/


Author      : Avinash Gupta
Web         : www.eXtremeElectronics.co.in
                   
**********************************************************************/

#include <avr/io.h>
#include <util/delay_basic.h>

void Wait(uint8_t delay)
{
   //Delay Function

   uint8_t i;
   for(i=0;i<delay;i++)
   {
      _delay_loop_2(0);
   }
}
void main()
{

   //Set the PORTD7 as output
   DDRD=0B10000000;

   while(1)
   {
      PORTD|=0b10000000;   //Binary value 1=LED off

      Wait(30);

      PORTD&=0b01111111;   //0=LED on.

      Wait(30);


   }
}

If you don't understand the program don't worry, the next tutorial will teach you how to setup and use general purpose IO ports in AVR.

Go to Project->Configuration Options to bring the Project option dialog.

AVR Studio main window

Fig - Setting CPU frequency and compiler optimization

 
Enter the CPU frequency. If you are using xBoard™ or xBoard™ MINI enter 16Mhz i.e. 16000000. In addition, select optimization as -O2. Click ok. Now you have entered the code now time to compile and build the project. Press F7 or select Build->Build or click the toolbar button for Build active configuration. If the code is error free AVR studio will show you the following message.

AVR Studio Build Success

Fig - Message

 

“Build succeed with 1 warning. Don’t worry about the one warning it is due to the fact that ANSI standard suggest that return type of main() must be one, but for MCU platform there is no environment or operating system that will receive this returned value. So return type of main() is void.

Now you have successfully compiled you first project, what you have got after compilation is a “.hex file”. You can find it in a folder named “default” in you project folder. It has same name as you project, in this case “hello.hex”

 

Finding the hex file

Fig - Finding "hello.hex" file

 

 

Step II Programming the MCU with “hello.hex”.

NOTE: YOU CAN ALSO GET A HELLO.HEX FILE FROM THE CD. LOOK IN THE FOLDER HEX IN THE SUPPORT DISK.

NOTE: The drivers for USB AVR Programmer must be Installed as described in its documentation

Now its time to burn this hex file to your MCU. To know how to burn the hex file to you MCU refer to you programmers manual. You can use eXtreme electronics USB AVR Programmer to burn hex files to you mcu (see shop section). Detailed procedure is given in “programmer” folder in its support CD.

Connect the USB Programmer to your PCs USB port. Make sure you connect it to that USB port in you installed it during its installation. Wait for a “ding” sound from PC. Now the programmer is installed correctly. The GREEN LED will glow to show programmer is ready.

Launch eXtreme Burner – AVR from Desktop Icon or Start Menu. You will get a screen similar to this.
(Please Install it from CD:\USB AVR Programmer\Software\Setup.exe)

eXtreme Burner - AVR, Main Screen


The software is very easy to use.

eXtreme Burner - AVR, Burn Progress.

 

Step III Electrical Connections.

xBoard has a on board LED that can be connected to PORTD bit 7. Short JUMPER J1, this will connect the LED with PORTD7. The power indicator LED of board should glow and the LED connected to the MCU’s port should blink on and off.

On Board LED

 

 

Now you can relax and enjoy that light blinking with all that modern sophisticated technology behind it and you first dedicated embedded program doing all the magic.

Now go on with your imagination tweak the program, modify delay and switching logic to get interesting patterns blinking. The limit is your imagination.

 

Note

Note: For More information on using AVR studio see AVR GCC Plug-in Help in the Help Menu

 

 

<< Return To Help Index