DOCX

lab1rev4

By Elsie Cooper,2014-10-16 18:13
7 views 0
lab1rev4

Ngee Ann Polytechnic

    School of Engineering

    Electrical Engineering Division

    Microcontroller & Applications

Laboratory 1: Introduction to ;Vision4, an Integrated

    Development Environment (IDE) for programming the 8051.

    (2 weeks)

Objectives

    1. Learn about the ;Vision4 IDE

    2. Write an Assembly program

    3. Build a ;Vision4 project

    4. Do a simulation for Program1 using ;Vision4 DEBUG (do outside

    the lab)

    5. Do a simulation for Program1 using Proteus ISIS Professional

    6. Transfer Program1 to AT89S8253 microcontroller flash memory

    using ELNEC BeeProg+

    The MCS-51 family of micro-controllers includes the 8031, 8051, 8751, 8052, 8032 etc. Each of these controllers are slightly different in terms of the on-chip memory size and the number of timers. In our lab, we will generally refer to the basic device which is the 8051 micro-controller.

    Micro-controllers are used in many systems which perform dedicated, control oriented functions. In order for these systems to work, a program must first be written and loaded into the memory (usually a form of ROM) of the microcontroller so that the system can behave in a predictable manner.

    There are many software IDEs that are available for you to create this program and one of them is KEIL ;Vision.

See these websites:

    ;Vision4 http://www.youtube.com/watch?v=gXXo_4m46qYand

    ;Vision4 http://www.microdigitaled.com/8051/Software/keil_tutorial.pdf

    Microcontroller Tutorial ttp://www.youtube.com/watch?v=rRrCpcLllOM

    In this lab exercise we will begin by building a simple project that comprises one assembly language program. Please refer to the recommended text The

    8051 Microcontroller and Embedded Systems Using Assembly and C for the list of assembly language instruction set to learn more.

     1

IMPORTANT

    Please load the software listed in the Software section of the MeL website into

    your computer.

    Summary of steps for a microcontroller project

    Step 1

    Use KEIL ;Vision to key

    your source file, built the

    project and generate the

    HEX file

    Step 4

    Built the hardware circuit

    Step 2

    Use Proteus ISIS

    Professional to draw the

    circuit

    Step 5

    Use ELNEC flash memory

    programmer and transfer

    your HEX file to the Step 3

    microcontrollerUse Proteus ISIS

    Professional to simulate

    your circuit and source

    code

     2

Creating a 8051 Project using ;Vision4

Start windows

Before we begin, create a folder in your local drive and call it MA. This is where

    we will save our files.

To begin go to

    All Programs ; Keil ;Vision4 or click the icon on the desktop .

    If you are starting for the very first time, ;Vision4 may provide you with a sample program in C language called Hello World. We will close this by selecting ‘Project’ from the menu bar and then select ‘close project’. Your

    screen should look like this.

     3

Create a New Project

Go to the top toolbar.

    Click on Project ; New ;Vision Project. The “Create New Project” panel opens up.

    Make sure the file type is program1 (*.uvproj). Make sure the folder to be saved into is the MA folder. Under file name, key in PROGRAM1. Press Save.

     4

    When the window “Select Device for Target ‘Target 1” appears, click Atmel as shown.

Select ATMEL AT89S8253 from the list of micro-controllers.

    Remember the microcontroller we will use throughout this module is the:

     5

Click on No when the following pop-up window appears.

6

Your screen should look as shown below.

Create a Source File

Click on File ; New. You will see a new work area named Text1. This is where

    you will write your source code.

Key in the source code given in Table 1 Program1.

Table 1 Program1

    ;PROGRAM1

    CSEG AT 0000H

    LJMP START

    CSEG AT 0036H

START:

    MOV P0,#0ffH

    READCODE:

    MOV A,P0

    XRL A,#0H

    JZ READCODE

    MOV B,P0

    FLASH:

    MOV A,#0H

    MOV P1,A

     7

CALL DELAY

CPL A

    MOV P1,A

CALL DELAY

    DJNZ B,FLASH

    LJMP $

CSEG AT 0100H

DELAY:

     MOV R2,#10

    LOOP2:MOV R1,#250

    LOOP1:MOV R0,#0H

    LOOP0:DJNZ R0,LOOP0

     DJNZ R1,LOOP1

     DJNZ R2,LOOP2

RET

     END

After keying in and making sure that it is correct, save your source code by

    selecting File ; Save As.

The Save As panel appears. Select the MA folder that you have created and

    save this file as PROGRAM1.A51. It is very IMPORTANT that you save the

    program as PROGRAM1.A51.

     8

    Note that it is alright to use the same name as the project file. This should not cause any confusion because program1.a51 is the source file whereas program1. uvproj is the project file.

    Source code is not case sensitive. You can use capitals, lower case or a mixture as you wish.

    After the save operation, the screen will look as shown below. The source file will be color coded.

If it is not, click Edit ; Configuration ; Colors & Fonts ; 8051: Editor Asm

    Files. Select the Foreground Color as follows:

Text ;

    Comment ;

Keyword ;

Label ;

     9

Built or Compile your Source Code

    Right Click on “Source Group 1” and select “Add Files to Group ‘Source Group 1’.

    A pop-up window appears. If you do not see any files it is because you need to specify the file type as ASM Source file instead of the default C Source file.

    Once you make the change you should see PROGRAM1 (The file you just typed in and saved as PROGRAM1.a51).

    Click once on PROGRAM1 (it should now be highlighted and appear in the “File name” Section. Click on the “Add” button.

Now you should see that “Source Group1” comprises PROGRAM1.a51.

    You may now select “Close”.

     10

Report this document

For any questions or suggestions please email
cust-service@docsford.com