Unformatted text preview:

CS/ECE 5780/6780: Embedded SystemDesignJohn RegehrLecture 2: 68HC12 Architecture & Lab 1 IntroductionDuff’s Devicevoid foo (int x, int *y, int *z) {switch (x % 8) {case 0:do {*y++ = *z++;case 7:*y++ = *z++;...case 1:*y++ = *z++;} while ((x -= 8) > 0);}}Puzzle WinnersIDaniel Stewart ParkerIAlex FreshmanIBrian fairesLab TimesLab timesITuesday 2:00–5:00IFriday 2:00–5:00IMonday 2:00–5:00We’ll start labs the week after nextPlease send a prioritized list to teach-cs5780 by Friday nightIntel 4004I4-bit BCDI92 kHzIntel 8008 (1972)I8-bitI500 kH zIntel 8080 (1974)I2 MHzIConsidered to be the firsttruly usablemicroprocessorIntel 8086-8088 (1978)Intel 286 (1982)Intel386TM(1985)Intel486TMDX CPU (1989)IntelR PentiumR(1993)IntelR PentiumRPro (1995)IntelR PentiumRII (1997)IntelR PentiumRIII (1999)IntelR PentiumR4 (2000)MicrocontrollersIDuring early 1980s, microcontrollers began to be des igned.IWhile microprocessors were optimized for speed and memorysize, microcontrollers were optimized for power and physicalsize.IIntel produced the 8051 microcontroller.IMotorola produced the 6805, 6808, 6811, and 6812.IIn 1999, Motorola shipped its 2 billionth MC68HC05microcontroller.IIn 2004, Motorola spun off its microcontroller division asFreescale Semiconductor.6812 ArchitectureITwo se parate 8-bit accumulators (A,B) or one combined16-bit accumulator (D).ITwo 16-bit index registers (X,Y).I8-bit condition code register.IPowerful bit-manipulation instructions.ISupports 16-bit add/subtract, 32 × 16 unsigned/signeddivide, 16 × 16 fractional divide, 16 × 16 unsigned/signedmultiply, and 32 + (16 × 16) multipl y and accumulate.IStack pointer points to the top element and grows downward.RegistersCondition Code RegisterAddress Map for MC9S12C32Address (hex) Size Device Contents$0000 to $03FF 1K I/O$3800 to $3FFF 2K RAM Variables and stack$4000 to $7FFF 16K EEPROM Program and constants$C000 to $FFFF 16K EEPROM Program and constantsExternal I/O PortsPort 48-pin Shared FunctionsPort A PA0 Address/Data BusPort B PB4 Address/Data BusPort E PE7, PE4, PE1, PE0 System Integration ModulePort J − Key wakeupPort M PM5-PM0 SPI, CANPort P PP5 Key wakeup, PWMPort S PS1-PS0 SCIPort T PT7-PT0 Timer, PWMPort AD PAD7-PAD0 Analog-to-Digital ConverterMC9S12C32 Block DiagramDigital Representations of NumbersINumbers are represented as a binary sequence of 0’s and 1’s.IEach 8-bit byte is stored at a different address.IA byte can be represented usin g two hexadecimal digits.%10110101 = $B5 (0xB5 in C)N = 128 · b7+ 64 · b6+ 32 · b5+ 16 · b4+ 8 · b3+ 4 · b2+ 2 · b1+ b0(unsigned)N = −128 · b7+ 64 · b6+ 32 · b5+ 16 · b4+ 8 · b3+ 4 · b2+ 2 · b1+ b0(signed)IProgrammer mu st track if a number is signed or unsigned.IWhile addition and subtraction use same hard ware, separatehardware is required for multiply, divide, and shift right.IA byte can also represent a character using the 7-bit ASCIIcode.16-Bit Words (Double Bytes)IEndian comparison for the 16-bit number $03E8:IFreescale microcontrollers use the big endian approach.Fixed-Point NumbersIIn embedded systems, fixed-point is often preferred overfloating point since it is simpler, more memory efficient, andoften all that is required .fixed-point number ≡ I · ∆where I is a variable integer and ∆ is a fixed constant.IIf ∆ = 10n, then called decimal fixed-point.IIf ∆ = 2n, then called binary fixed-point.IThe value of ∆ cann ot be changed during program execution,and it likely onl y appears as a comment in the code.Precision, Resolution, and RangeIPrecision is the total num ber of dis tinguish able values.IResolution is the smallest difference that can be represented.IRange is the minimum and maximum values.IExample: A 10-bit ADC wi th a range of 0 to +5V, has aprecision of 210= 1024 values, and a resolution of 5V/1024 orabout 5mV.IThis could be accurately stored in a 16-bit fixed-point numberwith ∆ = 0.001V.Overflow and Drop-OutIOverflow is when the result of calc ulation is outside the range.IDrop-out is when an intermediate result cannot berepresented.IExample:M = (53 ∗ N)/100 versus M = 53 ∗ (N/100)IPromotion to higher precision avoids overflow.IDividing last avoids drop-out.Fixed-Point ArithmeticILet x = I · ∆, y = J · ∆, z = K · ∆.z = x + y K = I + J (addition)z = x − y K = I − J (subtraction)z = x · y K = (I · J)/∆ (multiplication)z = x/y K = (I · ∆)/J (division)IIf ∆ is different, then must first convert one of the twonumbers to use the ∆ of the other.IIf ∆ is different, binary fixed- point i s more convenient asconversion can be done with shifting rather thanmultiplication/division.NotationIw is 8-bit signed (-128 to +127) or unsigned (0 to 255)In is 8-bi t signed (-128 to +127)Iu is 8-bit unsigned (0 to 255)IW is 16-bit signed (-32787 to +32767) or unsigned (0 to65535)IN is 16-bit signed (-32787 to +32767)IU is 16-bit unsigned (0 to 65535)I= [addr] specifies an 8-bit read from addressI= {addr} specifies a 16-bit read from address (big endian)I=< addr > specifies a 32-bit read from address (big endian)I[addr] = specifies an 8-bit write to addressI{addr} = specifies a 16-bit write to address (big endian)I< addr >= specifies a 32-bit write to address (big endian)Assembly LanguageIAssembly language instructions have four fields:Label Opcode Operand(s) Commenthere ldaa $0000 RegA = [$0000]staa $3800 [$3800] = RegAldx $3802 RegX = {$3802}stx $3804 {$3804} = RegXIAssembly instructions are translated i nto machine code:Object code Instruction Comment$96 $00 ldaa $0000 RegA = [$0000]Addressing ModesIAn addressing mode is a way for an instruction to locate itsoperand(s)IAbout 80% of understanding assembly language isunderstanding the addressing modesISome simple addressing modes:IInherent addressing mode (INH)IImmediate addressing mode (IMM)IDirect page addressing mode (DIR)IExtended addressing mode (EXT)IPC relative addressing mode (REL)Inherent Addressing ModeIUses no operand field.Obj code Op Comment$3F swi Software interrupt$87 clra RegA = 0$32 pula RegA = [RegSP]; RegSP=RegSP+1Immediate Addressing ModeIUses a fixed constant.IData is included in the machine code.Obj code Op Operand Comment$8624 ldaa #36 RegA = 36IWhat is the d ifferen ce between ldaa #36 and ldaa #$24?Direct Page Addressing ModeIUses an 8-bit address to access from addresses $0000 to$00FF.Obj code Op Operand Comment$9624 ldaa 36 RegA = [$0024]IWhat is the d ifferen ce between ldaa #36 and ldaa 36?Extended Addressing


View Full Document

U of U CS 5780 - Lecture Notes

Documents in this Course
Lab 1

Lab 1

5 pages

FIFOs

FIFOs

10 pages

FIFOs

FIFOs

5 pages

FIFO’s

FIFO’s

12 pages

MCU Ports

MCU Ports

12 pages

Serial IO

Serial IO

26 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?