Appendix Embedded system development using texaS




Yüklə 138.27 Kb.
tarix28.02.2016
ölçüsü138.27 Kb.

Introduction to Embedded Microcomputer Systems Lecture 2.

Appendix 1. Embedded system development using TExaS




A1.1. Introduction to TExaS




TExaS supports all five phases of software development:

• defining the microcomputer type and memory configuration,

• writing the program source code using an editor,

• assembling source code and loading object code into memory,

• interfacing external components,

• debugging the program by running it on the interactive simulator.


Observation: Hiding windows will improve the simulation speed.
Checkpoint A1.1: What is an assembly source code?
Program file (*.rtf) source code.

TheLog.rtf logs information

TheList.rtf the assembly listing

TheCRT.rtf the input/output data of a CRT terminal



Microcomputer file (*.uc) internal microcomputer

I/O Device file (*.io) external I/O devices

switches, LEDs, LCDs, keyboard, the CRT, motors, IR and sensors.



Stack file (*.stk) holds temporary information

Scope file (*.scp) used for debugging

Plot file (*.plt) display graphical information
Checkpoint A1.2: An oscilloscope graphically displays information about an electronic circuit. Which parameter is displayed on the y-axis and which parameter is displayed on the x-axis.

Checkpoint A1.3: How does a logic analyzer differ from an oscilloscope?
Checkpoint A1.4: What is object code?

A1.2. Major components of TExaS


editor

assembler

source code to object code

instruction set simulator

bus cycle activity and the extensive error checking

I/O port simulator

external device simulator

unique aspect of this simulator is the error checking.

• execution of an illegal instruction,

• read/write to an undefined address,

• stack underflow (a read/write from unimplemented memory),

• write to ROM, EPROM, EEPROM,

read from unprogrammed ROM, EPROM, EEPROM,

• read from RAM that has not yet been written to,

• read from an unimplemented I/O port.


Figure A1.7. Simple microcomputer system with four inputs and four outputs.

A1.3. Developing assembly software


modifying an existing example

readme.txt

start from scratch
Top down embedded system design

first draw a data flow graph

choose inputs, outputs

choose data structures

define major hardware/software modular blocks

estimate calculations/sec, memory size

choose a processor family

next draw a call graph showing the control linkage

design at a very high level using pseudo code

design at a lower level using a high level language like C

convert the software by hand into assembly

simulate prototype

test and redesign algorithms

choose a specific microcontroller

build and test actual prototype


A1.3.2. Modifying an existing assembly language program


find and open an existing system.

reconfigure the processor and external I/O ports

write assembly code

configuring the simulation modes

running and debugging
Online homework submission

You can work together in groups of any size, but everyone enters a separate online solution.

STEP 1: Log into the Homework Service at the URL  https://hw.utexas.edu/ 

Unique number: 16165

There is no keypad, but please spell your name exactly how the university officially knows you.

STEP 2:


Download: Students' Instructions

Download: First Homework

STEP 3: Work one homework question. Log in again and submit its answer before next class period.

STEP 4: Continue submitting answers until due time.

STEP 5: Download the solutions after due time.

Architecture defines how the various computer components are connected.

The 6812 has a von Neumann architecture





Figure 3.7. four basic components of the 6812 processor.


Figure 3.8. The 6812 has 6 registers.

2. Information.



Chapter 2 objectives are:

• how numbers are stored on the computer,

• how characters are represented,

• precision, basis, hexadecimal, big and little endian,

• arithmetic and logic operations,

• condition code bits,

• convert character strings and binary numbers,

• fixed-point and floating point numbers.


Precision is the number of distinct or different values.

The last column in both tables are rough approximations, and the ranges are given for unsigned decimal numbers.




binary bits

bytes

exact range

exact alternatives

approximate decimal digits

8

1

0 to 255

256

≈ 2½

10




0 to 1023

1024

≈ 3

12




0 to 4095

4096

≈ 3¾

16

2

0 to 65535

65536

≈ 4¾

20




0 to 1,048,575

1,048,576

≈ 6

24

3

0 to 16,777,215

16,777,216

≈ 7½

30




0 to 1,073,741,823

1,073,741,824

≈ 9

32

4

0 to 4,294,967,295

4,294,967,296

≈ 9¾

n

[[n/8]]

0 to 2n

2n

≈ n*log10(2)

Table 2.1. Relationships between various representations of precision.
Table 2.2. represents THE DEFINITION of decimal digits. The specification of decimal digits goes 4, 4½, 4¾, 5, with no other possibilities in between. The numbers 4.3 and 4⅛ are not valid representations of decimal digits.


decimal digits

exact range

exact alternatives

approximate bits

3

0 to 999

1,000

≈ 10



0 to 1999

2,000

≈ 11



0 to 3999

4,000

≈ 12

4

0 to 9999

10,000

≈ 13



0 to 19,999

20,000

≈ 14



0 to 39,999

40,000

≈ 15

5

0 to 99,999

100,000

≈ 17



0 to 199,999

200,000

≈ 18



0 to 399,999

400,000

≈ 19

6

0 to 999,999

1,000,000

≈ 20



0 to 199,999

2,000,000

≈ 21



0 to 3,999,999

4,000,000

≈ 22

N

0 to 10N-1

10N

≈ N*log2(10)



0 to 2*10N-1

2*10N

≈ N*log2(10)+1



0 to 4*10N-1

4*10N

≈ N*log2(10)+2

Table 2.2. Standard definition of decimal digits.

2.1. Hexadecimal representation


base 16

convenient to represent binary information




Hex Digit

Decimal Value

Binary Value

0

0

%0000

1

1

%0001

2

2

%0010

3

3

%0011

4

4

%0100

5

5

%0101

6

6

%0110

7

7

%0111

8

8

%1000

9

9

%1001

A or a

10

%1010

B or b

11

%1011

C or c

12

%1100

D or d

13

%1101

E or e

14

%1110

F or f

15

%1111

Table 2.3. Definition of hexadecimal representation.

environment

binary

hex

decimal

Freescale

%01111010

$7A

122

Intel and TI

01111010B

7AH

122

C language




0x7A

122

Table 2.4. Comparison of various formats.

Easy to convert from binary to hexadecimal:





Figure 2.1. Example conversion
Checkpoint 2.4: Convert the binary number %01000101 to hexadecimal.
Checkpoint 2.5: Convert the binary number %110010101011 to hexadecimal.
to convert from hexadecimal to binary we can:

1) convert each hexadecimal digit

into its corresponding 4-bit binary nibble,

2) combine the nibbles into a single binary number.





Figure 2.2. Example conversion from hex to binary.


2.3. 8-bit numbers

2.3.1. 8-bit unsigned numbers





Figure 2.4. 8-bit binary format.
the value of the number is
N = 128•b7 +64•b6 +32•b5 +16•b4 +8•b3 +4•b2 +2•b1 +b0
Notice that the significance of bit n is 2n.

There are 256 different unsigned 8-bit numbers.




binary

hex

Calculation

decimal

%00000000

$00




0

%01000001

$41

64+1

65

%00010110

$16

16+4+2

22

%10000111

$87

128+4+2+1

135

%11111111

$FF

128+64+32+16+8+4+2+1

255

Table 2.5. Examples
Checkpoint 2.10: Convert the binary number %10010010 to unsigned decimal.
Checkpoint 2.11: Convert the hex number $A2 to unsigned decimal.
The basis of a number system

a subset from which linear combinations of the basis elements can be used to construct the entire set.


{1, 2, 4, 8, 16, 32, 64, 128}
The values of a binary number system can only be 0 or 1. For example, 69 is (0,1,0,0,0,1,0,1)(128,64,32,16,8,4,2,1)


Number

Basis

Need it?

bit

Operation

202

128

yes

bit 7=1

subtract 202-128

74

64

yes

bit 6=1

subtract 74-64

10

32

no

bit 5=0

none

10

16

no

bit 4=0

none

10

8

yes

bit 3=1

subtract 10-8

2

4

no

bit 2=0

none

2

2

yes

bit 1=1

subtract 2-2

0

1

no

bit 0=0

none

Table 2.6. Example conversion.

1100,1010 is $CA


2.3.2. 8-bit signed numbers





Figure 2.4. two’s complement number system
N= -128•b7+64•b6 +32•b5 +16•b4 +8•b3 +4•b2 +2•b1 +b0
There are 256 different signed 8-bit numbers.


binary

hex

Calculation

dec

%00000000

$00




0

%01000001

$41

64+1

65

%00010110

$16

16+4+2

22

%10000111

$87

-128+4+2+1

-121

%11111111

$FF

-128+64+32+16+8+4+2+1

-1

Table 2.7. Example conversions
For the signed 8-bit number system the basis is
{1, 2, 4, 8, 16, 32, 64, -128}
Observation: The most significant bit in a two’s complement signed number will specify the sign.

%11111111 could represent either 255 or -1.


You keep track of the number format.

The computer can not determine if signed or unsigned.

signed or unsigned by the assembly instructions you select

e.g., mul versus smul




Number

Basis

Need it

bit

Operation

-100

-128

yes

bit 7=1

subtract -100 - -128

28

64

no

bit 6=0

none

28

32

no

bit 5=0

none

28

16

yes

bit 4=1

subtract 28-16

12

8

yes

bit 3=1

subtract 12-8

4

4

yes

bit 2=1

subtract 4-4

0

2

no

bit 1=0

none

0

1

no

bit 0=0

none

Table 2.8. Example conversion
Observation: To take the negative of a two’s complement signed number we first complement (flip) all the bits, then add 1.
A second way to convert negative numbers into binary is to first convert them into unsigned binary, then do a two’s complement negate.

A third way to convert negative numbers into binary is to first add 256 to the number, then convert the unsigned result to binary using the unsigned method.



Common Error: An error will occur if you use signed operations on unsigned numbers, or use unsigned operations on signed numbers.
Maintenance Tip: To improve the clarity of our software, always specify the format of your data (signed versus unsigned) when defining or accessing the data.

2.3.3. Character information


American Standard Code for Information Interchange (ASCII) code.
           BITS 4 to 6

 




0

1

2

3

4

5

6

7

 

0

NUL

DLE

SP

0

@

P

`

p

B

1

SOH

DC1

:

1

A

Q

a

q

I

2

STX

DC2

!

2

B

R

b

r

T

3

ETX

DC3

#

3

C

S

c

s

S

4

EOT

DC4

$

4

D

T

d

t

 

5

ENQ

NAK

%

5

E

U

e

u

0

6

ACK

SYN

&

6

F

V

f

v

 

7

BEL

ETB

'

7

G

W

g

w

T

8

BS

CAN

(

8

H

X

h

x

O

9

HT

EM

)

9

I

Y

i

y

 

A

LF

SUB

*

:

J

Z

j

z

3

B

VT

ESC

+

;

K

[

k

{

 

C

FF

FS

,

<

L

\

l

;

 

D

CR

GS

-

=

M

]

m

}

 

E

SO

RS

.

>

N

^

n

~

 

F

S1

US

/

?

O

_

o

DEL

 Table 2.11. Standard 7-bit ASCII.

2.4.1. 16-bit unsigned numbers


A word or double byte contains 16 bits


Figure 2.5. 16-bit binary format.

N = 32768•b15 + 16384•b14 + 8192•b13 + 4096•b12

+ 2048•b11 + 1024•b10 + 512•b9 + 256•b8

+ 128•b7 + 64•b6 + 32•b5 + 16•b4 + 8•b3 + 4•b2

+ 2•b1 + b0
For the unsigned 16-bit number system the basis is
{1, 2, 4, 8, 16, 32, 64, 128,

256, 512, 1024, 2048, 4096, 8192, 16384, 32768}



2.4.2. 16-bit signed numbers





Figure 2.5. 16-bit binary format.
N = -32768•b15 + 16384•b14 + 8192•b13 + 4096•b12

+ 2048•b11 + 1024•b10 + 512•b9 + 256•b8

+ 128•b7 + 64•b6 + 32•b5 + 16•b4 + 8•b3 + 4•b2

+ 2•b1 + b0
For the signed 16-bit number system the basis is
{1, 2, 4, 8, 16, 32, 64, 128,

256, 512, 1024, 2048, 4096, 8192, 16384, -32768}



Common Error: An error will occur if you use 16-bit operations on 8-bit numbers, or use 8-bit operations on 16-bit numbers.
Maintenance Tip: To improve the clarity of your software, always specify the precision of your data when defining or accessing the data.

2.4.3. Big and little endian






Figure 2.6. Example of big and little endian formats



Figure 2.7. Example of big and little endian formats


2.5. Programming numbers in assembly language


w is signed 8-bit -128 to +127

or unsigned 8-bit 0 to 255

n is signed 8-bit -128 to +127

u is unsigned 8-bit 0 to 255

W is signed 16-bit -32787 to +32767

or unsigned 16-bit 0 to 65535

N is signed 16-bit -32787 to +32767

U is unsigned 16-bit 0 to 65535

=[addr] 8-bit read from addr

={addr} 16-bit read from addr

[addr]= 8-bit write to addr

{addr}= 16-bit write to addr

ldaa #w RegA=w

ldaa u RegA=[u]

ldaa U RegA=[U]

staa u [u]=RegA

staa U [U]=RegA

bra U PC=U





Figure 2.10. The ldaa Data instruction loads



Figure 2.11. The staa PORTB instruction stores
Checkpoint 2.30: Write assembly code that copies the data from memory location 10 to memory location 20.
Checkpoint 2.31: Write assembly code that writes the binary %11000111 to Port B.


Mark W. Welker (From Jonathan W. Valvano)


Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azrefs.org 2016
rəhbərliyinə müraciət

    Ana səhifə