HCS12 Microcontroller and Embedded Systems: Using Assembly and C with CodeWarrior 1 st Edition

Similar documents
THE AVR MICROCONTROLLER AND EMBEDDED SYSTEMS. Using Assembly and С

This page intentionally left blank

CHAPTER 2: AVR ARCHITECTURE & ASSEMBLY LANGUAGE PROGRAMMING

Database Concepts. David M. Kroenke UNIVERSITATSBIBLIOTHEK HANNOVER

Lecture Objectives. Introduction to Computing Chapter 0. Topics. Numbering Systems 04/09/2017

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

Mark II Aiken Relay Calculator

World Wide Web PROGRAMMING THE PEARSON EIGHTH EDITION. University of Colorado at Colorado Springs

EE 308: Microcontrollers

ony Gaddis Haywood Community College STARTING OUT WITH PEARSON Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto

Visual C# Tony Gaddis. Haywood Community College STARTING OUT WITH. Piyali Sengupta. Third Edition. Global Edition contributions by.

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

ELEG3923 Microprocessor Ch.0 & Ch.1 Introduction to Microcontroller

Chapter 2 Sections 1 8 Dr. Iyad Jafar

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

PIC Microcontroller and

Introduction to the 9S12 Microcontroller

2011 Pearson Higher Education, Mazidi, Naimi, and Naimi Pearson Higher Education, 2011 Pearson Higher Education,

PROBLEM SOLVING USING JAVA WITH DATA STRUCTURES. A Multimedia Approach. Mark Guzdial and Barbara Ericson PEARSON. College of Computing

MECE336 Microprocessors I

Integrated Approach. Operating Systems COMPUTER SYSTEMS. LEAHY, Jr. Georgia Institute of Technology. Umakishore RAMACHANDRAN. William D.

Prelude to Programming

Microcontrollers. Microcontroller

CPEG300 Embedded System Design. Lecture 3 Memory

Ali Karimpour Associate Professor Ferdowsi University of Mashhad

ELEG3924 Microprocessor

History of the Microprocessor. ECE/CS 5780/6780: Embedded System Design. Microcontrollers. First Microprocessors. MC9S12C32 Block Diagram

64 Megabit Serial Flash Memory with 4Kbyte Uniform Sector

Microcomputer Architecture and Programming

EN25QH64 64 Megabit Serial Flash Memory with 4Kbyte Uniform Sector

16 Megabit Serial Flash Memory with 4Kbyte Uniform Sector

32 Megabit Serial Flash Memory with 4Kbyte Uniform Sector

Chapter 2 COMPUTER SYSTEM HARDWARE

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

Pearson New International Edition. The 8051 Microcontroller and Embedded Systems Mazidi Mazidi McKinlay Second Edition

Business Driven Data Communications

Microprocessors/Microcontrollers

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

Introduction to Embedded Systems and Chapter 1: Introduction to HCS12/MC9S12. EE383: Introduction to Embedded Systems University of Kentucky

CREATED BY M BILAL & Arslan Ahmad Shaad Visit:

Introduction to Computers - Chapter 4

Exam I Review February 2017

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

8051 Microcontroller


Microprocessors And Microcontroller

SOLUTION MANUAL FOR THE 8051 MICROCONTROLLER 4TH EDITION BY MACKENZIE AND PHAN

CC411: Introduction To Microprocessors

MACHINES AND MECHANISMS

64 Megabit Serial Flash Memory with 4Kbyte Uniform Sector

PIC Architecture & Assembly Language Programming. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7

Microprocessors I MICROCOMPUTERS AND MICROPROCESSORS

32 Megabit Serial Flash Memory with 4Kbyte Uniform Sector

Search Engines Information Retrieval in Practice

ELEG3923 Microprocessor Ch.2 Assembly Language Programming

Week 1. Introduction to Microcomputers and Microprocessors, Computer Codes, Programming, and Operating Systems

Introduction to Microcontrollers

FIFTH SEMESTER DIPLOMA EXAMINATION IN ENGINEERING/ TECHNOLOGY-MARCH 2014 EMBEDDED SYSTEMS (Common for CT,CM) [Time: 3 hours] (Maximum marks : 100)

EN25S32 32 Megabit 1.8V Serial Flash Memory with 4Kbyte Uniform Sector

MA Unit 4. Question Option A Option B Option C Option D

Addition and Subtraction of Hexadecimal Numbers Simple assembly language programming

N bit is set if result of operation in negative (MSB = 1) Z bit is set if result of operation is zero (All bits = 0)

CodeWarrior. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Module Contents of the Module Hours COs

32 Megabit Serial Flash Memory with 4Kbyte Uniform Sector

Workbook for C++ THIRD EDITION. Yedidyah Langsam, Ph.D. Brooklyn College of the City University of New York. Custom Publishing

MECHATRONICS. William Bolton. Sixth Edition ELECTRONIC CONTROL SYSTEMS ENGINEERING IN MECHANICAL AND ELECTRICAL PEARSON

Access ComprehGnsiwG. Shelley Gaskin, Carolyn McLellan, and. Nancy Graviett. with Microsoft

CRYPTOGRAPHY AND NETWORK SECURITY

32 Megabit Serial Flash Memory with 4Kbyte Uniform Sector

ME 515 Mechatronics. A microprocessor

Computer Organization and Assembly Language (CS-506)

CC411: Introduction To Microprocessors

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

University of Kashan Faculty of Electrical and Computer Engineering Department of Computer Engineering. Lecture note 2

1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE:

Essentials of Database Management

Dec Hex Bin ORG ; ZERO. Introduction To Computing

Roberto Muscedere Images and Text Portions 2003 Prentice Hall 1

EE 308: Microcontrollers

CS/ECE 5780/6780: Embedded System Design

Memory & Simple I/O Interfacing

What is an Addressing Mode?

Menu. word size # of words byte = 8 bits

A Simple MC9S12 Program

DIGITAL SYSTEM FUNDAMENTALS (ECE421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE422)

Data Structures and Abstractions with Java

Secure Microcontrollers for Smart Cards. AT90SC Summary

Microcontroller & Interfacing

Module 2: Introduction to AVR ATmega 32 Architecture

DATA AND COMPUTER COMMUNICATIONS

ME 475 Lab2 Introduction of PIC and Programming. Instructor: Zhen Wang

EN25S40 4 Megabit 1.8V Serial Flash Memory with 4Kbyte Uniform Sector

EE4390 Microprocessors. Lessons 2, 3 68HC12 Hardware Overview, Subsystems, and memory System

8 Megabit Serial Flash Memory with 4Kbyte Uniform Sector

MICROPROCESSOR BASED SYSTEM DESIGN

Real-Time Systems and Programming Languages

Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

Interface DAC to a PC. Control Word of MC1480 DAC (or DAC 808) 8255 Design Example. Engineering 4862 Microprocessors

Transcription:

Online Instructor s Manual to accompany HCS12 Microcontroller and Embedded Systems: Using Assembly and C with CodeWarrior 1 st Edition Muhammad Ali Mazidi Danny Causey Prentice Hall Boston Columbus Indianapolis New York San Francisco Upper Saddle River Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo

Copyright 2009 Pearson Education, Inc., publishing as Prentice Hall, Upper Saddle River, New Jersey and Columbus, Ohio. All rights reserved. Manufactured in the United States of America. This publication is protected by Copyright, and permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission(s) to use material from this work, please submit a written request to Pearson Education, Inc., Permissions Department, One Lake Street, Upper Saddle River, New Jersey. Many of the designations by manufacturers and seller to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed in initial caps or all caps. 10 9 8 7 6 5 4 3 2 1 ISBN-13: 978-0-13-504837-5 ISBN-10: 0-13-504837-0

CHAPTER 0: INTRODUCTION TO COMPUTING SECTION 0.1: NUMBERING AND CODING SYSTEMS 1. 2. 3. 4. 5. 6. 7. (a) 12 10 = 1100 2 (b) 123 10 = 0111 1011 2 (c) 63 10 = 0011 1111 2 (d) 128 10 = 1000 0000 2 (e) 1000 10 = 0011 1110 1000 2 (a) 100100 2 = 36 10 (b) 1000001 2 = 65 10 (c) 11101 2 = 29 10 (d) 1010 2 = 10 10 (e) 00100010 2 = 34 10 (a) 100100 2 = 24 16 (b) 1000001 2 = 41 16 (c) 11101 2 = 1D 16 (d) 1010 2 = 0A 16 (e) 00100010 2 = 22 16 (a) 2B9 16 = 0010 1011 1001 2, 697 10 (b) F44 16 = 1111 0100 0100 2, 3908 10 (c) 912 16 = 1001 0001 0010 2, 2322 10 (d) 2B 16 = 0010 1011 2, 43 10 (e) FFFF 16 = 1111 1111 1111 1111 2, 65535 10 (a) 12 10 = 0C 16 (b) 123 10 = 7B 16 (c) 63 10 = 3F 16 (d) 128 10 = 80 16 (e) 1000 10 = 3E8 16 (a) 1001010 = 0011 0110 (b) 111001 = 0000 0111 (c) 10000010 = 0111 1110 (d) 111110001 = 0000 1111 (a) 2C+3F = 6B (b) F34+5D6 = 150A (c) 20000+12FF = 212FF (d) FFFF+2222 = 12221 8. (a) 24F-129 = 126 16

(b) FE9-5CC = A1D 16 (c) 2FFFF-FFFFF = 30000 16 (d) 9FF25-4DD99 = 5218C 16 9. (a) Hex: 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 (b) Binary: 11 0000, 11 0001, 11 0010, 11 0011, 11 0100, 11 0101, 11 0110, 11 0111, 11 1000, 11 1001. ASCII (hex) Binary 0 30 011 0000 1 31 011 0001 2 32 011 0010 3 33 011 0011 4 34 011 0100 5 35 011 0101 6 36 011 0110 7 37 011 0111 8 38 011 1000 9 39 011 1001 10. 000000 22 55 2E 53 2E 41 2E 20 69 73 20 61 20 63 6F 75 "U.S.A. is a cou 000010 6E 74 72 79 22 0D 0A 22 69 6E 20 4E 6F 72 74 68 ntry".."in North 000020 20 41 6D 65 72 69 63 61 22 0D 0A America".. SECTION 0.2: DIGITAL PRIMER 11. A B 1 2 3 C 4 5 6 12. A B C Y 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 1

13.. A B 1 2 3 C 4 5 6 14. A B C Y 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 15. A B C 1 2 3 4 5 6 A B C Y 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 1 0 0 1 1 1 1 16. A B C Y 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 0

17. A B C Y 0 0 0 1 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 0 18. LSB 19. LSB 20. CLK D Q No X NC Yes 0 0 Yes 1 1 SECTION 0.3: SEMICONDUCTOR MEMORY 21. (a) 4 (b) 4 (c) 4 (d) 1 048 576, 2 20 (e) 1024K (f) 1 073 741 824, 2 30 (g) 1 048 576 K (h) 1024M (i) 8388608, 8192K

22. Disk storage capacity / size of a page = (2*2 30 ) / (25*80) = 1 million pages 23. (a) 9FFFFh 10000h = 8FFFFh = 589 824 bytes (b) 576 kbytes 24. 2 32 1 = 4 294 967 295 25. (a) FFh, 255 (b) FFFFh, 65535 (c) FFFF FFFFh, 4 294 967 295 (d) FFFF FFFF FFFF FFFFh, 18 446 744 073 709 551 615 26. (a) 2 16 = 64K (b) 2 24 = 16M (c) 2 32 = 4096 Mega, 4G (d) 2 48 = 256 Tera, 262144 Giga, 268435456 Mega 27. Data bus is bidirectional, address bus is unidirectional (exit CPU). 28. The storage of the chip is measured in Megabits while the Computer memory is measured in Megabytes. 29. True, the more address lines the more memory locations. 30. True, the memory location size is fixed. 31. True, the more data lines the more memory locations 32. True 33. access time 34. True 35. electrically erasable 36. True 37. DRAM 38. SRAM 39. DRAM and SRAM 40. (c) 41. (c) 42. (a) 32Kx8, 256K (f) 8Kx1, 8K (b) 8Kx8, 64K (g) 4Kx8, 32K (c) 4Kx8, 32K (h) 2Kx8, 16K (d) 8Kx8, 64K (i) 256Kx4, 1M (e) 4Mx1, 4M (j) 64Kx8, 512K 43. (a) 128K 14 8 (f) 256K 8 4 (b) 256K 15 8 (g) 8M 20 8 (c) 512K 16 8 (h) 16M 11 4 (d) 2M 18 8 (i) 512K 16 8 (e) 512K 16 8 44. 4000h - 7FFFh 45. A0 A11 A12 A13 1 2 1 2 3 ~CS

46. 8000h - 8FFFh, B000h - BFFFh, E000 - EFFFh 47. A0 A12 8kx8 A13 A14 A15 Vcc 1 2 3 6 4 5 U? A B C G1 G2AN G2BN 74138 Y0N Y1N Y2N Y3N Y4N Y5N Y6N Y7N 15 14 13 12 11 10 9 7 ~CS Each controls 8K bytes block 48. 6000h - 7FFFh, C000h - DFFFh, E000h - FFFFh 49. A0 A14 32kx8 A15 A16 A17 Vcc 1 2 3 6 4 5 U? A B C G1 G2AN G2BN 74138 Y0N Y1N Y2N Y3N Y4N Y5N Y6N Y7N 15 14 13 12 11 10 9 7 ~CS Each controls 32K bytes block 50. 4000h - 7FFFh, 8000h - BFFFh, C000h - FFFFh SECTION 0.4: CPU AND HARVARD ARCHITECTURE 51. PC ( Program Counter ) 52. ALU is responsible for all arithmetic and logic calculations in the CPU. 53. Address, control and data SECTION 0.5: RISC ARCHITECTURE 54. RISC stands for "Reduced Instruction Set Computer". CISC stands for "Complex (or Complete) Instruction Set Computer". 55. CISC

56. RISC 57. RISC 58. CISC Full file at https://fratstock.eu

CHAPTER 1: THE HCS12 MICROCONTROLLERS: HISTORY AND FEATURES SECTION 1.1: MICROCONTROLLERS AND EMBEDDED PROCESSORS 1. False. 2. True. 3. True. 4. True. 5. CPU, RAM, ROM, EEPROM, I/O, Timer, Serial COM port, ADC. 6. RAM and ROM. 7. Keyboard, mouse, printer. 8. Computing power and compatibility with millions and millions of PCs. 9. PIC 16x Microchip Technology, 8051 - Intel, AVR Atmel, Z8 Zilog, 68HC11 Freescale Semiconductor (Motorola). 10. 8051. 11. Power consumption. 12. The ROM area is where the executable code is stored. 13. Very, in case there is a shortage by one supplier. 14. Suppliers other than the manufacturer of the chip. 15. B is absolutely wrong, 16 bit software can not run on a 8 bit system due to special instructions and registers. But A can be true (in the case of software compatibility). SECTION 1.2: OVERVIEW OF THE CPU12 AND CPU08 16. 512 Kbytes 17. 64 Kbytes 18. 8 Kbytes 19. 4K K1bytes 20. 2 21. Flash 22. Flash 23. (a) 14 Kbytes (b) 12 Kbytes (c) 2 Kbytes 24. OTP (see the letter 'C')

CHAPTER 2: HCS12 ARCHITECTURE & ASSEMBLY LANGUAGE PROGRAMMING SECTION 2.1: INSIDE THE HCS12 1. 16 2. 8 3. 8 4. FFH 5. necessary 6. The result is 28H, stored in Accumulator A. 7. In (a) and (d) the operand exceeds allowed range. The syntax of (g) is wrong, since ADDA can have only one operand ( ADDA mybyte, or, ADDA #$50 ). 8. (a), (c) and (d) exceed the allowed range. 9. The result is 44H in accumulator A. 10. The result is FFH in accumulator A. 11. FFH 12. False. There is only one register A and one register B. SECTION 2.2: THE HCS12 MEMORY MAP 13. 64KBytes 14. True 15. False. Registers are part of Register space. 16. True 17. False 18. False. There are also Register Space and unused space. 19. (a) 14 KBytes (b) 1 KBytes 20. Data RAM is used to store temporary data, and when power goes off its information is lost. But, we use EEPROM to store nonvolatile data that must remain intact even when the power is turned off. 21. Yes, some chips have no EEPROM, page 66. 22. No, the HCS12 needs RAM for volatile data. 23. Flash. 24. 32 KBytes. 25. 0000H 26. Registers 000-3FFF, RAM 0800-3FFF, EEPROM 7000-7FFF, Code ROM C000-FFFF SECTION 2.3: HCS12 ADDRESSING MODES 27. 800H 28. LDAA #$30 STAA $805 LDAA #$97 STAA $806

29. LDAA #$55 STAA $300 STAA $301 STAA $302 STAA $303 STAA $304 STAA $305 STAA $306 STAA $307 STAA $308 30. LDAA #5F STAA PORTB 31. (b) LDAA $30 is Extended mode addressing. 32. (a) Direct, (b) Immediate, (c) Extended, (d) Immediate, (e) Inherent, (f) Inherent 33. (a) 3 Byte, (b) 2 Byte, (c) 3 Byte, (d) 2 Byte, (e) 1 Byte, (f) 1 Byte 34. 0000H 35. Direct Addressing 36. Immediate Addressing 37. Direct Addressing 38. Extended Addressing 39. Invalid 40. 800H 8FFH 41. Registers X and Y 42. True SECTION 2.4: CONDITION CODE REGISTER 43. 8 bit 44. C = bit 0, H = bit 5 45. V = bit 1, N = bit 3 46. The C flag = 1 when there is a carry out from the D7 bit after an 8-bit arithmetic operation. 47. The H flag = 1 when there is a carry from the D3 to D4 bit after an 8-bit arithmetic operation. 48. FFH + 1 = 100H, but since register A is only 8-bit the Z and C flags are both = 1. 49. (a) 118H, so C = 1 (b) FFH, so C = 0 (c) 104H, so C = 1 50. LDAA #$55 ADDA #$55 ADDA #$55 STAA $1200

SECTION 2.5: HCS12 DATA FORMAT AND DIRECTIVES 51. MYDAT_1 = 37H MYDAT_2 = 62H MYDAT_3 = 47H MYDAT_4 = 50H MYDAT_5 = C8H MYDAT_6 = 41H MYDAT_7 = AAH MYDAT_8 = FFH MYDAT_9 = 90H MYDAT_10 = 7EH MYDAT_11 = 0AH MYDAT_12 = 0FH 52. DAT_1 = 16H DAT_2 = 56H DAT_3 = 99H DAT_4 = 20H DAT_5 = F6H DAT_6 = 7BH 53. R0 EQU $300 R1 EQU $301 R2 EQU $302 R3 EQU $303 R4 EQU $304 R5 EQU $305 (a) LDAA #$11 STAA R0 STAA R1 STAA R2 STAA R3 STAA R4 STAA R5 (b) CLRA ADDA R0 ADDA R1 ADDA R2 ADDA R3 ADDA R4 ADDA R5

SECTION 2.6: INTRODUCTION TO HCS12 ASSEMBLY PROGRAMMING AND SECTION 2.7: ASSEMBLING AND LINKING A HCS12 PROGRAM 54. low - high 55. Assembly. 56. Assembler 57. True. 58. List file, with extension.lst. 59. False. 60. False. END is optional for HCS12, but is good practice to make the code readable. 61. No. 62. Because they only tell the assembler what to do and do not generate any op-codes. 63. True. 64. False. 65. True. 66. The file with.s19 extension is downloaded. 67. Three file extensions include:.asm,.lst, and.s19. SECTION 2.8: STACK AND DATA TRANSFER INSTRUCTIONS 68. The stack pointer points to the last used location. 69. decremented, 2 70. incremented, 2 71. False, RAM is used for stack. 72. True