1 / 32

Physics 413 Chapter 1 : Introduction to the HCS 12 Microcontroller

Physics 413 Chapter 1 : Introduction to the HCS 12 Microcontroller. Computer Architecture. What is a Digital Computer ? A computer is essentially a fast electronic calculating machine.

zoie
Download Presentation

Physics 413 Chapter 1 : Introduction to the HCS 12 Microcontroller

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Physics 413Chapter 1: Introduction to the HCS 12 Microcontroller

  2. Computer Architecture • What is a Digital Computer ? A computer is essentially a fast electronic calculating machine. • What is a program ? A program is a set of very simple instructions that a computer can understand. Examples of simple instructions are ADD two numbers, Is X > Y?, COPY A into the memory. • What is Machine Language ? The set of exceedingly simple and primitive instructions that a computer can understand is called the Instruction Set or Machine Language.

  3. Architecture and Organization • Computer Architecture deals with the design of those components of a computer that are accessible to a programmer. For instance, the Motorola 6800 does not have a MUL instruction but the Pentium does. • Computer Organization deals with the implementation of the architecture and may be transparent to the programmer. For instance, precisely how is MUL implemented in the hardware?

  4. Levels of Abstraction • L5 High‑level Language (C++, Java) • L4 Assembly Language • L3 Operating System • L2 Instruction Set Architecture (ISA) • L1 Microarchitecture Level • L0 Digital Logic Level • Transistors

  5. A Brief History of Computers • First Generation ‑ Vacuum Tubes ‑ 1945‑1955 ENIAC (Electronic Numerical Integrator and Computer) had 18,000 Vacuum Tubes, 1500 relays and weighed 30 tons • Second Generation ‑ Transistors ‑ 1955‑65 ‑ PDP ‑8 (DEC) • Third Generation ‑ IC ‑ 1965‑80 ‑ IBM 360 • Fourth Generation ‑ VLSI ‑ Intel and AMD Processors

  6. Moore’s Law The number of transistors on a chip doubles every 18 months

  7. All about microprocessors and microcontrollers • ROM is where the program that initializes the PC is stored. • RAM access is fast • ADDRESS BUS carries the address of RAM, ROM, and other peripherals • HCS12 has 16 multiplexed address and data lines • DATA BUS carries data back and forth between the microprocessor and RAM, ROM, and other peripherals.

  8. Memory • Big Endian: 4 bytes arranged as:0123 (32‑bit word) • Little Endian: 4 bytes arranged 3210 (32‑bit word) • DRAM Organization • nxn matrix structure is popular for large memory sizes • RAS ‑ Row Address Strobe • CAS ‑ Column Address Strobe • RAS ‑ CAS strategy reduces the number of pins but slows down access because two addressing cycles are required • SRAM Fast for cache

  9. ROM • ROM • PROM • EPROM ‑ UV erasable • EEPROM ‑ Electrically erasable byte at a time • FLASH ‑ electrical block erasable ‑ digital film ‑ more like RAM!

  10. HCS12 Data Sheet http://www.freescale.com/files/microcontrollers/doc/data_sheet/HCS12DFAMILYPP.pdf

  11. HCS12 Architecture A B A + B = D X Y SP PC CCR

  12. Straight-line Programming In Paris they simply stared when I spoke to them in French ; I never did succeed in making those idiots understand their own language Mark Twain , The Innocents Abroad, 1869

  13. My First Program • CLRA Clears accumulator A ( A = 0 ) • INC A This instruction does this: A + 1 A • SWI Stop (software interrupt)

  14. Op-codes Assembly LanguageMemory LocationOp-codes CLRA 2000 87 INCA 2001 42 SWI 2002 3F

  15. My Second Program LDAA # $ 12 ADDA # $ 15 SWI

  16. Object Code . . . Program # 2 Assembly LanguageMemory LocationOp-codes LDAA # $ 12 2000 86 2001 12 ADDA # $ 15 2002 8B 2003 15 SWI 2004 3F

  17. Addressing Modes • Inherent (implied) : Simplest with no operand. One-byte op-code. Examples: INCA and CLRA • Immediate : Operand specified is immediate (no memory access). Examples: LDAA # $ 12 and ADDA # $ 15

  18. Immediate and Direct Modes • Immediate LDAA # $ 12 Load the hex number 12 • op-code 86 12 • Direct LDAA $ 12 Load from memory location 0012 • op-code 96 12

  19. My Third Program Assembly LanguageMemory LocationOp-codes LDAA # $ 04 STAA $ 15 LDAA # $ 08 ? ? ADDA $ 15 SWI

  20. My Third Program Assembly LanguageMemory LocationOp-codes LDAA # $ 04 2000 86 04 STAA $ 15 2002 97 15 LDAA # $ 08 2004 86 08 ADDA $ 15 2006 9B 15 SWI 2008 3F

  21. Extended Addressing Mode • The extended addressing mode becomes indispensable when memory locations beyond the zero page must be addressed. [This is the case for the HCS12 on the Dragon12 Board in the lab] • Here, as always, an example is worth a thousand words: • LDAA $3C5E Load A from memory location 3C5E • Op-codes B6 3C 5E

  22. Three Trick Questions • What is the outcome of B6 00 2A ? • What is the outcome of LDAA # $ 3C5E ? • What is the outcome of STAB $3C44 ?

  23. Trick Questions . . . Answered! • What is the outcome of B6 00 2A ? Legal but not very smart. • What is the outcome of LDAA # $ 3C5E ? Not Legal • What is the outcome of STAB $3C44 ? O.K. and op-code is F7 3C 44

  24. Index Register X is a 16-bit register How are the following three instructions different? LDX # $ 5C42 LDX $ 5C42 LDX $ 5C

  25. Index Register • LDX #$ 5C42 The number 5C42 is loaded into X • LDX $ 5C42 Numbers from 5C43 and 5C42 loaded • LDX $ 5C Numbers from 005D and 005C loaded

  26. Indexed Addressing Mode LDAA 0,X loads accumulator A with the contents of the memory location pointed to by the index register X. LDAA 4,X loads accumulator A with the contents of the memory location pointed to by X+4

  27. Transfer and Exchange! • TFR D,X transfers the contents of D to X • TFR X, B transfers bits 0-7 of X to B • EXG A,B swaps A and B

  28. Move it! • Memory to memory transfer • movb $1000,$2000 copies the (8-bit)contents of memory location $1000 to the memory location $2000 • movw0,X,0,Ycopies the 16-bit word pointed to by X to the memory location pointed to by Y.

  29. Examples Galore • ADDA The outcome is A + M A • ADDA # $ 2B8B 2B • ADDA $ 3C9B 3C • ADDA $ 5B24AB 5B 24

  30. Carry Bit in CCR • ADCA The outcome is A + M + C A • Use this instruction when expecting a carry. Incidentally, CLC will clear the carry bit.

  31. Indexed Addressing Mode LDX # $ 0050 LDAA 0,X ADDA 1,X SWI Program adds two numbers stored in memory locations 0050 and 0051

  32. D-bug12 Assembler ASM 2000 Begin assembly at address 2000 End Assembly LOAD Load S-Records into memory MD Memory Display MM Modify Memory RD Display CPU registers RM Modify CPU Register Contents PC 2000 loads 2000 into PC T Trace (single-step)

More Related