How to use AVR Studio for Assembler Programming



Similar documents
Microcontroller Systems. ELET 3232 Topic 8: Slot Machine Example

AVR Butterfly Training. Atmel Norway, AVR Applications Group

Why using ATmega16? University of Wollongong Australia. 7.1 Overview of ATmega16. Overview of ATmega16

An Introduction to MPLAB Integrated Development Environment

S-SupremaConfigurationGuide-DOC 7/23/2014. Suprema Biometrics Configuration Guide ACS OnSite Aparato

13 Managing Devices. Your computer is an assembly of many components from different manufacturers. LESSON OBJECTIVES

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

Start A New Project with Keil Microcontroller Development Kit Version 5 and Freescale FRDM-KL25Z

AUTOMATIC NIGHT LAMP WITH MORNING ALARM USING MICROPROCESSOR

DEPLOYING A VISUAL BASIC.NET APPLICATION

Deposit Direct. Getting Started Guide

MONITORING PERFORMANCE IN WINDOWS 7

Choosing your Preferred Colours in Windows

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

Building A RISC Microcontroller in an FPGA

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

Reviewing documents with track changes in Word 2013

Designing a Graphical User Interface

Producing Standards Based Content with ToolBook

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Lecture 22: C Programming 4 Embedded Systems

How to Program a Commander or Scout to Connect to Pilot Software

DsPIC HOW-TO GUIDE Creating & Debugging a Project in MPLAB

Lab 1: Introduction to Xilinx ISE Tutorial

How to increase virtual memory in Windows XP with Service Pack 2

Creating a Project with PSoC Designer

CREATE A 3D MOVIE IN DIRECTOR

Microcontroller Code Example Explanation and Words of Wisdom For Senior Design

1. Tutorial Overview

5. Tutorial. Starting FlashCut CNC

Downloading Driver Files

64-Bit Compatibility with Micromeritics Applications

Authorware Install Directions for IE in Windows Vista, Windows 7, and Windows 8

BASLER ACE QUICK INSTALLATION GUIDE

How to read this guide

CodeWarrior Development Studio for Freescale S12(X) Microcontrollers Quick Start

3 IDE (Integrated Development Environment)

Work with Arduino Hardware

From the list of Cooperative Extension applications, choose Contacts Extension Contact Management System.

Executive Dashboard Updated December 2015

ET-BASE AVR ATmega64/128

How to install USB driver (MICRO/I)

2.0 Command and Data Handling Subsystem

Update Instructions

Cloud Extend Tutorial

Project Manager Editor & Debugger

Vodafone PC SMS (Software version 4.7.1) User Manual

Microsoft Visual Studio 2010 Instructions For C Programs

INF-USB2 and SI-USB Quick Start Guide

Motion Control Products Application note Exporting AC500 tags for use with Panel Builder

FileNet System Manager Dashboard Help

Programming A PLC. Standard Instructions

Quick Start Tutorial. Using the TASKING* Software Development Tools with the Intel 8x930 Family Evaluation Board

Nuvoton Nu-Link Debug Adapter User Manual

USER GUIDE Version 2.0

Introduction to LogixPro - Lab

Last updated: October 4, einvoice. Attorney Manual

Step Motor Controller. Application Note. AVR360: Step Motor Controller. Theory of Operation. Features. Introduction

8051 MICROCONTROLLER COURSE

IGSS. Interactive Graphical SCADA System. Quick Start Guide

Packages Opening the Package Maintenance Form Adding a New Package Edit Package Item Details Form... 11

CORSAIR GAMING KEYBOARD SOFTWARE USER MANUAL

Mobius 3 Circuit Board Programming Instructions

Company Setup 401k Tab

Lab 1: Full Adder 0.0

SKP16C62P Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

XRD CONVERSION USER S MANUAL

BIGPOND ONLINE STORAGE USER GUIDE Issue August 2005

Medical Student Training on Electronic Notes Documentation. For Third and Fourth year Medical Students

Creating a Simple Visual C++ Program

Building an Embedded Processor System on a Xilinx Zync FPGA (Profiling): A Tutorial

Surf it Easy. User Guide

Internet Explorer 7. Getting Started The Internet Explorer Window. Tabs NEW! Working with the Tab Row. Microsoft QUICK Source

Common issues in GACship can be categorized as follows: Related to IE and pop-up blocker settings. Contact your Hub Operator

vtcommander Installing and Starting vtcommander

IT Quick Reference Guides Using Windows 7

Working with SQL Server Integration Services

AVR034: Mixing C and Assembly Code with IAR Embedded Workbench for AVR. 8-bit Microcontroller. Application Note. Features.

Service & Support. How can you establish a connection between an S PLC and SIMATIC NET OPC? S PLC, SIMATIC NET OPC.

After opening the Programs> Xilinx ISE 8.1i > Project Navigator, you will come to this screen as start-up.

Appendix K Introduction to Microsoft Visual C++ 6.0

Special Lecture. Basic Stamp 2 Programming. (Presented on popular demand)

PowerWorld Simulator

ITCS QUICK REFERENCE GUIDE: EXPRESSION WEB SITE

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

3. Programming the STM32F4-Discovery

PRODUCTIVITY THROUGH INNOVATION 600 CONTROL DIRECT DRIVE TECHNICAL/OPERATION MANUAL

User Guide for External Candidates

Chapter 13. PIC Family Microcontroller

PowerPoint 2007: Animations Contents

Getting Started with CodeXL

Outlook . User Guide IS TRAINING CENTER. 833 Chestnut St, Suite 600. Philadelphia, PA

9 Working With DICOM. Configuring the DICOM Option

KPN SMS mail. Send SMS as fast as !

1. Click the File tab 2. Click "Options" 3. Click "Save" 4. In the line labeled "Default file location", browse to the desired folder 5.

Auditing UML Models. This booklet explains the Auditing feature of Enterprise Architect. Copyright Sparx Systems Pty Ltd

TRILOGI 5.3 PLC Ladder Diagram Programmer and Simulator. A tutorial prepared for IE 575 by Dr. T.C. Chang. Use On-Line Help

POOSL IDE User Manual

Microsoft Outlook 2007 Calendar Features

PRINTER DRIVER GUIDE (KODAK 305 Photo Printer)

Transcription:

How to use AVR Studio for Assembler Programming Creating your first assembler AVR project Run the AVRStudio program by selecting Start\Programs\Atmel AVR Tools\AVR Studio. You should see a screen like this: To create a new project, click on New Project (new Projects can also be created later by selecting Project\New from the Menu system). On the next dialog Box, select Atmel AVR assembler, enter the project name (eg first ) and navigate to your desired location by clicking the button labelled. 1

Your screen should look like: Click Next. Now select the debug platform as AVR Simulator with the device ATmega8515 so our program will be run on the simulator. Your screen should look like this: 2

Now click Finish and you will be shown a screen like this: In your first.asm editor, copy and paste in the following code: My first assembler program.include "8515def.inc" include the 8515 definition file.def temp = r16 define a temporary register In this example, we will output values to PORTB RESET: Let's set the Data Direction Register for PORTB (DDRB) (0 = input, 1 = output) pin nums: 76543210 VVVVVVVV ldi temp, 0b11111111 this could also be 0xFF out DDRB, temp output the value to DDRB ldi temp, 0x01 load 1 into temp LOOP: Now, we continually loop writing to output B followed by rotating left once, and loop back out PORTB, temp output temp to PORTB rol temp rotate temp left rjmp LOOP jump back to LOOP 3

Then save your file (File\Save or Ctrl-S) and build it (Build\Build or F7). Your code should appear like this: And your build output should appear like this: Notice the code has been built with no errors or warnings and that the code is 12 bytes in size (six assembler instructions at two bytes each). 4

Using the AVR Simulator to test your first program Now we are ready to simulate the code. In order to see what the code is doing, we need a better view. So click the I/O View tab at the bottom of the docked window pane. Expand the Register 16-31 tree and the I/O ATMEGA8515 tree and then expand PORTB. Your I/O View panel should look like this: Now we are ready to start simulating. Select Debug\Start Debugging (or Ctrl-Alt-Shift-F5). You will now see a yellow arrow pointing to the next instruction to be executed, similar to this picture: 5

To step through each instruction, select Debug\Step Into (or press F11). Do this once now. The yellow arrow should be pointing to the next instruction (the out instruction). Before moving to the next instruction, check also the register list. You should see that the value for r16 has changed from 0x00 to 0xFF. Press F11 again. Now the DDRB value in the I/O View tree has changed to 0xFF, which is also shown by the dark squares. Each dark square represents one pin, from pin7 to pin0 (left to right). This means you have successfully written 0xFF (or 0b11111111 to DDRB). Pressing F11 a couple more times sets first register 16 and then PORTB to be the value 0x01. Next to PORTB, you will see 7 white squares (pins 7 to 1) and one dark square (pin 0). As you successively press F11, you will see the dark pin on PORTB shift left. This is what your I/O View screen might look like after a few iterations: Now, let s say we wanted to further debug the program by editing the value in register 16? No matter what the current value of r16 is, let s give it the value 0x1C. To do this, open up the Register view (View\Register or Alt-0) and you should see a screen like this: In order to change a value, double-click on the value for the register you need. In this case, doubleclick on the value next to R16. (In the picture above, you would click on the number 0x10). 6

You should see a screen like this: Enter in the value 1C as above, and click OK. This change should be reflected in red in your Register View window as well as having changed the value of r16 under your I/O Tree View. Clicking F11 a few more times gives you these screen shots: In order to stop debugging and return to editing your code, select Debug\Stop Debugging (or Ctrl- Shift-F5). 7

Simulating Inputs What if, rather than continually outputting values, our AVR microcontroller was used to read values from one port and output to another. For example, we could use the AVR in this way: PORTB = NOT(PORTA) Create a new project, or change the code in the current project. Copy and paste in the following code: My second assembler program.include "8515def.inc" include the 8515 definition file.def temp = r16 define a temporary register Continually read in from PORTA and write out to PORTB RESET: Let's set the Data Direction Registers (DDRA & DDRB) (0's = inputs, 1's = outputs) ldi temp, 0x00 out DDRA, temp ldi temp, 0xFF out DDRB, temp LOOP: Now, we continually loop, reading from PORTA pins, negating the value and writing to PORTB in temp, PINA read in from PORTA s input pins neg temp negate temp register out PORTB, temp write out to PORTB rjmp LOOP jump back to LOOP Save (Ctrl-S) and Build (F7) your new project. Your assembly should complete with no errors again, but this time, the code size should display as 16 bytes (8 instructions at 2 bytes each). Now, let s set up your I/O View to see both PortA and PortB. Collapse registers r16-r31, and expand Port A. Your view should look like this: 8

Select Debug\Start Debugging and press F11 to step through the code and iterate the loop a couple of times. Regardless of the number of loop iterations you step through, your screen will stay in the following state: That is, Port A s pins are constantly inputting 0x00, and thus Port B is always outputting 0xFF. In order to test your program, you need to simulate various inputs at the PINA pins. So, while your program is running, create a test bit-pattern on the PINA pins by clicking on each individual square. For example, the diagram below shows the bit pattern 0-1-0-1-1-0-1-0 (or 0x5A). Once you ve entered this, complete one whole iteration of the loop by repeatedly pressing F11. Your screen should look like this: Try testing other bit patterns to confirm that your code will work regardless of what bit pattern is applied to the inputs pins of Port A. You can also select Debug\AutoStep (Alt-F5) to have the code automatically stepped through. You may wish to investigate the other hardware peripherals available for inspection under your I/O View tree. These include configuration registers for the ADC, external interrupts, timers and even internal CPU registers such as the Status Register (SREG), or internal processor registers such as the Program Counter. 9