Docsity

Chapter 2 Microcontroller Application | ECE 4510, Study notes of Microcomputers

Partial preview of the text

Download Chapter 2 Microcontroller Application | ECE 4510 and more Study notes Microcomputers in PDF only on Docsity!

ECE 4510/

Microcontroller ApplicationsMicrocontroller Applications

Ch

t

Chapter 2

Dr. Bradley J. BazuinAssociate Professor

Department of Electrical and Computer Engineering

College of Engineering and Applied SciencesCollege of Engineering and Applied Sciences

Chapter 2 Overview

p

-^

Software Development

p

-^

Software Development Environment–

ICC12 Compiler/Assembler/Linker/Loader

-^

D-Bug12 Microcontroller Resident Debugger

-^

Assembly Programming–

Assembly Language Code SyntaxAssembly Language Code Syntax

-^

Assembler Directives

-^

Assembly Language Command Utilization

-^

Multiple Byte/Word Precision Math

-^

Multiple Byte/Word Precision Math

-^

Binary Coded Decimals (BCD)

-^

BranchingOth

I^

t^

ti

-^

Other Instructions

-^

Loops for time delay

Software Development Issues

p

-^

Software development starts with problem definition

p

p

–^

Problem presented by the application must be fully understoodbefore any program can be written

-^

Next step is to lay out an overall plan of how to solve theproblemp –

The plan is also called an algorithm

-^

Algorithm is a sequence of computational steps that transforms theinput into the outputinput into the output

-^

An algorithm can be expressed in pseudo code that is very muchlike C or Pascal (or the target language for the code)

-^

An algorithm provides not only the overall plan for solving the

-^

An

algorithm provides not only the overall plan for solving the problem but also documentation for the S/W to be developed

Software Development Issues

p

-^

An alternative for providing the overall plan for solving

p

g

p

g

software problems is the use of flowcharts–

A flowcharts shows the way a program operatesIt illustrates the logic flow of the program

-^

It illustrates the logic flow of the program

-^

Flowchart symbols are classified as:

owc a t sy

bo s a e c ass

ed as:

–^

Terminal

-^

ProcessI^

t^

O t

t

–^

Input or Output

-^

Decision

-^

Subroutine

Software Development Flowchart

p

T

i^

l^

U

d^

h^

b^

i^

i^

d h

d^

f^

h

•^

Terminal – Used at the beginning and the end of each program–

When used at the beginning of a program, the word start is written insidethe symbolWh

d^

t th

d^

f^

th

d^

t^

i^

itt

i^

id

it

-^

When used at the end of a program, the word stop is written inside it

•^

Process – Indicates what must be done at this point in the program

i

execution–

Operations specified by the process box could be

-^

Shifting the contents of one general purpose register to a peripheral registerD

ti^

l^

t^

t

-^

Decrementing a loop count, etc

•^

Input/Output – Used to represent data that are either read or displayedb^

h by the computer

Software Development Flowchart

p

Decision

yes

A

off-

-^

Decision – Contains a question that can be answered yes or no Decision

no

A on-page connector

-^

A decision box has two exits, also marked yes or no

-^

Computer will take one action if the answer is yes and will take a different action ifthe answer is no

-^

On-page connector – Indicates that the flowchart continues elsewhere on theOn page connector

Indicates that the flowchart continues elsewhere on the

same page. The place where it is continued will have same label as the on-pageconnector

-^

Off-page connector – Indicates that the flowchart continues on another page

-^

After the programmer is satisfied with the flowchart, it is converted to sourcecode using assembly or C language

S^

u^ b

r o

u^

t i n

e

A

S^

u^ b

r o

u^

t i n

e

B

o^ f f - p

a^

g^ e

c^ o

n^

n^ e

c^

t o^

r

Software development Issues

p

-^

Assembly program:

y p

g

.area prog (abs)text

; Start of the program

.text

; Start of the program

_main::Ldaa $

; [$1000]

Æ

A

Adda $

; [A] + [$1001]

Æ

A

Adda $

; [A] + [$1002]

Æ

A

Staa $

;[A]

Æ

$^

;[

]^

swi

Software Development Testing

p

g

-^

Next major step in software development is testing the

j^

p

p

g

program–

Testing a program means testing for anomaliesThe first test is for normal inputs that are always expected

-^

The first test is for normal inputs that are always expected

-^

If the results are as expected, then the border line inputs are tested

-^

Then maximum and minimum values are tested

-^

Then illegal input values are tested

-^

If the algorithm includes several branches, then enoughvalues must be used to exercise all the possible branchesvalues must be used to exercise all the possible branches–

This is to make sure program will operate correctly under allpossible circumstances

Software Development Environment

p

-^

Create a project in the environment

p

j

-^

Load files containing code into the project

-^

For high-level languages: Compile into assembly language

-^

For assembly language: Assemble into object code module

-^

Link multiple object code modules into machine code

d l

module

-^

Load machine code module onto the target host

-^

Executing machine codeExecuting machine code–

For development: Use a monitor program or debugger to runmachine codeFor users: Execute machine resident code

-^

For users: Execute machine resident code

The Steps to CPU Code (1)

p

-^

The Hierarchy of operations: making object files

Your Software Tools

-^

Software Development Environment

p

–^

The Imagecraft Freescale CPU12 Development Tools

-^

ICCV7 for CPU12 – refereed to as ICC12 around WMU

-^

http://www imagecraft com/

-^

http://www.imagecraft.com/

-^

CPU Embedded Debugging Tool–

Freescale D-Bug

-^

NoICE with the background debugging module (BDM)–

ICE refers to an “In-Circuit Emulator”

Code File Generation

-^

Assembly Language

y

g

g

–^

Assembly Language directives

-^

Instruction to the assembler about the code Assembly Language Code

-^

Assembly Language Code

-^

C Language–

C language “PRAGMA”

-^

Instructions to the compiler/assembler about the code

–^

C Language Code

g^

g

Assembly Program Elements

y

g

-^

Assembler directives–

Defines data and symbol

-^

Reserves and initializes memory locationsSets assembler and linking condition

-^

Sets assembler and linking condition

-^

Specifies output format

-^

Specifies the end of a program

-^

Assembly language instructions–

HCS12/MC9S12 instructions

-^

Comments

-^

Comments–

Explains the function of a single or a group of instructions

Fields of a HCS12 Instruction

label:[:] operation operands ;comments

•^

Label field–

OptionalStarts with a letter and followed by

•^

Operand field–

Follows the operation field and is

-^

Starts with a letter and followed byletters, digits, or special symbols

-^

Can start from any column if endedwith “:”

p

separated from the operation field byat least one space

-^

Contains operands for instructions or

f^

bl

di

i

-^

Must start from column 1 if notended with “:”

•^

Operation field (opcode)

arguments for assembler directives

•^

Comment field–

Any line starts with an * or ; is a

p^

( p

-^

Contains the mnemonic of a machineinstruction or an assembler directive

-^

Separated from the label by at least

comment

-^

Separated from the operand andoperation field for at least one spaceOptional

ECE 2510

one space

-^

Optional