Top Banner
EMBEDDED SYSTEMS By: Nikhil Parashar 1
51

Embedded System Day 6

Jun 04, 2018

Download

Documents

Arvind Kumar
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 1/51

EMBEDDED SYSTEMS

By: Nikhil Parashar

1

Page 2: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 2/51

Course Contents

• Introduction to HC12 family, Processor Core

Architecture, MC9S12C32 Features, Block

Diagrams, Programming Models, Pin outs and

Signals, System Clock.

• Register Blocks and Memory Mapping, Modes

of Operation

• Addressing Modes and Assembly Language

Programming

Page 3: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 3/51

Programming Model

• Two index registers (X and Y)

• 16-bit stack pointer (SP)

16-bit program counter (PC)• 8-bit condition code résister (CCR)

Page 4: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 4/51

Page 5: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 5/51

Data Types

The CPU12 uses these types of data:

• Bits

• 5-bit signed integers

•8-bit signed and unsigned integers

• 8-bit, 2-digit binary-coded decimal numbers

• 9-bit signed integers

• 16-bit signed and unsigned integers

• 16-bit effective addresses

• 32-bit signed and unsigned integers

Page 6: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 6/51

Addressing Modes

Addressing modes determine how the central

processor unit (CPU) accesses memory locations to

be operated upon.

•Inherent

• Immediate

• Direct

• Extended

• Relative

• Indexed

Page 7: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 7/51

Inherent AM

• No operands or all operands are in internal

CPU registers.

• Eg.

NOP ;this instruction has no operands

INX ;operand is a CPU register

Page 8: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 8/51

Immediate AM

• Eg.

LDAA #$55

LDX #$1234LDY #$67

Page 9: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 9/51

Direct AM

Sometimes called zero-page addressing

Eg.

LDAA $55LDX $20

Page 10: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 10/51

Extended AM

The full 16-bit address of the memory location

Eg.

LDAA $F03B ; The value from address; $F03B is loaded into the

; A accumulator.

Page 11: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 11/51

Relative AM

• The relative addressing mode is used only by branchinstructions.

• Short conditional branch instructions

• long conditional branch instructions

• Short branch instructions consist ofan 8-bit opcode and a signed 8-bit offset contained in the

byte that follows the opcode.

• Long branch instructions consist of

an 8-bit prebyte, an 8-bit opcode, and a signed 16-bitoffset contained in the two bytes that follow theopcode.

Page 12: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 12/51

Page 13: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 13/51

Page 14: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 14/51

Index AM

Indexed addressing modes use a 16-bit CPU register and

additional information to create an effective address.

• 5-Bit Constant Offset Indexed Addressing

9-Bit Constant Offset Indexed Addressing• 16-Bit Constant Offset Indexed Addressing

• 16-Bit Constant Indirect Indexed Addressing

• Auto Pre/Post Decrement/Increment Indexed

Addressing• Accumulator Offset Indexed Addressing

• Accumulator D Indirect Indexed Addressing

Page 15: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 15/51

Bit Manipulation Instructions

• combination of two or a combination of three

addressing modes.

• BCLR

• BSET

• BRCLR

BRSET

Page 16: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 16/51

Addressing More than 64 Kbytes

• Some M68HC12 devices supports addressing a largermemory space than the standard 64 Kbytes.

• Uses fast on-chip logic to implement a transparentbank-switching scheme.

• HC12 system requires no external glue logic.• Interrupts do not need to be disabled during switching

because switching tasks are incorporated in specialinstructions that greatly simplify program access toextended memory.

• MCUs with expanded memory treat the 16 Kbytes ofmemory space from $8000 to $BFFF as a programmemory window.

Page 17: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 17/51

• Expanded-memory architecture includes an 8-bitprogram page register (PPAGE), which allows up to 25616-Kbyte program memory pages to be switched intoand out of the program memory window. This provides

for up to 4 Megabytes of paged program memory.• The CPU12 instruction set includes call subroutine in

expanded memory (CALL) and return from call (RTC)instructions, which greatly simplify the use ofexpanded memory space. These instructions also

execute correctly on devices that do not haveexpanded-memory addressing capability, thusproviding for portable code.

Addressing More than 64 Kbytes

Page 18: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 18/51

• $0000 - $03FF I/O PORTS

• $3800 - $3FFF INTERNAL RAM

$4000 - $7FFF INTERNAL EEPROM• $8000 - $9FFF EXTERNAL RAM

• $C000 - $FFFF INTERNAL EEPROM

Addressing More than 64 Kbytes

Page 19: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 19/51

Instruction Set• Data Transfer Instruction

1. Load & Store Instruction

2. Transfer & Exchange• Arithmetic Instruction

1. Addition & Subtraction

2. BCD Operation

3. Increment/Decrement

4. Multiplication/Division

• Logical Instruction

1. Boolean Logical Instruction

2. Bit Manipulation

3. Shift & Rotate

4. Compare & Test Instructions

• Branch Instruction1. Short conditional branches

2. Long conditional branches

3. Bit-condition branches

4. Loop Primitives

5. Jumps

Page 20: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 20/51

• Fuzzy Logic Instruction

1. Fuzzy Logic Membership Instruction

2. Fuzzy Logic Rule Evaluation Instructions3. Fuzzy Logic Weighted Average Instruction

• Maximum and Minimum Instructions

• Multiply and Accumulate Instruction

• Table Interpolation Instructions

• Index Manipulation Instructions

• Stacking Instructions

Pointer and Index Calculation Instructions• Stop and Wait Instructions

• Background Mode and Null Operations

Page 21: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 21/51

Page 22: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 22/51

• Transfer & Exchange Instructions

MOV Instruction

• AM for MOV Instruction are immediate,extended, and indexed addressing modes.

• The operand of an immediate mode instruction

is data, not an address.

• the operand of an immediate mode instruction is

data, not an address

Page 23: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 23/51

Transfer & Exchange Instructions

• MOVB ; Move a Byte of Data from

;One Memory Location to Another

• MOVW ; Move a Word of Data from

;One Memory Location to Another

Page 24: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 24/51

Addition & Subtraction

• ABA ; Add Accumulator B to

;Accumulator A

• ABX ; Add Accumulator B to Index

;Register X

• ABY ; Add Accumulator B to Index

;Register Y

• ADCA ; Add with Carry to A

• ADCB ; Add with Carry to B

Page 25: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 25/51

• ADDA ; Add without Carry to A

• ADDB ; Add without Carry to B

ADDD ; Add Double Accumulator• SBA ;Subtract Accumulators

Addition & Subtraction

Page 26: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 26/51

BCD OPERATION

• To add binary-coded decimal (BCD) operands,

use addition instructions that set the half-

carry bit in the CCR, then adjust the result

with the decimal adjust A (DAA) instruction.

Page 27: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 27/51

Increment/Decrement

M lti li ti /Di i i

Page 28: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 28/51

Multiplication/Division

• Signed and Unsigned 8- and 16-bit multiplication

L i l I t ti

Page 29: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 29/51

Logical Instructions• Boolean Logical Instructions

The Boolean logic instructions perform a logicoperation between an 8-bit accumulator or

the CCR and a memory value.

Page 30: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 30/51

Bit Manipulation Instructions

• These uses a mask value to test or change the

value of individual bits in A or in M.

Page 31: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 31/51

Shift & Rotate Instructions

Page 32: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 32/51

Page 33: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 33/51

Compare & Test Instructions

Page 34: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 34/51

Maximum & Minimum Instructions

Page 35: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 35/51

Branching OperationsBranch instructions cause execution flow to change when specific pre-

conditions exist and the changes are categorized as

• Resets,

• Interrupts,

• Subroutine calls,

• Conditional branches, and

• Jumps.

Branch operations can be of the types• Short conditional branches

• Long conditional branches

• Bit-condition branches

Types

Short BranchLong Branch

Bit Condition Branch

Loop Primitives

Jumps

Page 36: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 36/51

Page 37: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 37/51

• BSR and JSR are used to access subroutines in

the normal 64-Kbyte address space.

• The CALL instruction is intended for use in

MCUs with expanded memory capability.

Branching Operations

Page 38: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 38/51

Short Branch:

Page 39: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 39/51

Page 40: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 40/51

Long Branch

Page 41: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 41/51

Page 42: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 42/51

Page 43: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 43/51

Bit Conditional Branch Instructions

Page 44: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 44/51

Loop primitive

Page 45: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 45/51

Page 46: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 46/51

Interrupt Instructions

Page 47: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 47/51

Condition Code Instructions

Page 48: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 48/51

Stop & Wait Instructions

Page 49: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 49/51

Background Mode & Null

Page 50: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 50/51

• TExaS= Test EXecute & Simulate

Page 51: Embedded System Day 6

8/13/2019 Embedded System Day 6

http://slidepdf.com/reader/full/embedded-system-day-6 51/51

Assembler Directives

Group A Group B Group C Meaning

ORG ORG .ORG Origin of Memory

= EQU Define a constant Symbol

SET Define a constant Symbol

DC.B FCB .BYTE Allocate byte of storage with initialized valueFCC Create an ASCII string

DC.W FDB .WORD Allocate word of storage with initialized value

DC.L .LONG Allocate 32-bitlong word of storage with initialized value

DS.B RMB .BLKB Allocate byte of storage without initialization

DS.W .BLKW Allocate word of storage without initialization

DS.L .BLKL Allocate 32-bit word of storage without initialization

END END .END End of the source code