MC68HC12 Parallel I/O

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

EEL 4744C: Microprocessor Applications. Lecture 7. Part 2. M68HC12 Interrupt. Dr. Tao Li 1

Using the MC9S12 in Expanded Mode External Ports S12CPUV2 Reference Manual Multiplexed External Bus Interface (MEBI) Module V3 Block User Guide

The 9S12 in Expanded Mode - How to get into expanded mode Huang Chapter 14

The 9S12 in Expanded Mode - How to get into expanded mode Huang Chapter 14

Input and Output Ports. How do you get data into a computer from the outside?

EE 308 Spring 2011 The MC9S12 in Expanded Mode How to get into expanded mode

EE 308 Spring Lecture 28 March 30, 2012 Review for Exam 2. Introduction to the MC9S12 Expanded Mode

MC9S12 has 16 bit address and 16 bit data buses. Not enough pins on MC9S12 to allocate 35 pins for buses and pins for all other functions

The MC9S12 address, data and control buses The MC9S12 single-chip mode memory map Simplified write/read cycle. Address, Data and Control Buses

PRINCETON (VON NEUMAN) ARCHITECTURE MICROPROCESSOR

HC12 Built-In Hardware

Roberto Muscedere Images and Text Portions 2003 Prentice Hall 1

Using MSI Logic To Build An Output Port

The 9S12 in Expanded Mode - Using MSI logic to build ports Huang Chapter 14

Capstone Design Course. Lecture-2: The Timer

UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING

EE 308 Spring Lab on IIC Bus

AN Kbyte Addressing with the M68HC11. Overview

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

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume.

Introduction to Microcontrollers

UNIVERSITY OF HONG KONG DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING. Principles of Computer Operation

Go Gators! Relax! May the Schwartz be with you!

Ryerson University Department of Electrical and Computer Engineering ELE 538 Microprocessor Systems Final Examination December 8, 2003

538 Lecture Notes Week 5

EE 3170 Microcontroller Applications

University of Florida EEL 4744 Fall 1998 Dr. Eric M. Schwartz

538 Lecture Notes Week 5

Microcontrollers. Microcontroller

The MC9S12 in Expanded Mode Using MSI logic to build ports Using MSI logic to build an output port Using MSI logic to build an input port

EE 308 Spring A software delay

Introduction. ECE/CS 5780/6780: Embedded System Design. Memory-Mapped I/O. Isolated I/O. Expanded Mode. Multiplexed Address and Data Lines

Review for Exam III. Analog/Digital Converters. The MC9S12 has two 10-bit successive approximation A/D converters - can be used in 8-bit mode

ME 4447 / ME 6405: Introduction to Mechatronics

CHALMERS Lindholmen 1. Compare (a) a sand hour glass, (b) a pocket mechanical watch (c) a wrist quartz watch and (d) the Big

Computer Organization I. Lecture 28: Architecture of M68HC11

Chapter 8 Summary: The 8086 Microprocessor and its Memory and Input/Output Interface

EE 3170 Microcontroller Applications

Microcomputer Architecture and Programming

EE 308 Spring A software delay. To enter a software delay, put in a nested loop, just like in assembly.

Mark II Aiken Relay Calculator

Introduction to the MC9S12 Hardware Subsystems

ECE 367 -Experiment #1 Fall 2012

ASSIGNMENT 4: INTRODUCTION TO THE 68HC11. Out: Monday, Sep 29, 2003 Due Monday, Oct 6, 2003

CS/ECE 5780/6780: Embedded System Design

HCS12. Microcontrollers. Multiplexed External Bus Interface (MEBI) Module V3. Block User Guide

Total: EEL 3701 Digital Logic & Computer Systems Final Exam Fall Semester 2007 COVER SHEET: Re-Grade Information: 1 (10) 2 (10) 3 (10) 4 (14) 5 (14)

Introduction to Mechatronics. Fall Instructor: Professor Charles Ume. Interrupts and Resets

EE319 K Lecture 3. Introduction to the 9S12 Lab 1 Discussion Using the TExaS simulator. University of Texas ECE

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3

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

MICROPROCESSOR AND MICROCONTROLLER BASED SYSTEMS

ECE 3610 MICROPROCESSING SYSTEMS AN ENCRYPTED ASCII CODE DECODER

1a)[2] Connect the devices on the left column to items on the right column. Keypad 4x4

ECE/CE 3720: Embedded System Design

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

Wed. Aug 23 Announcements

PIC16F87X. 28/40-pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

M68HC11E Family. Data Sheet M68HC11. Microcontrollers M68HC11E/D Rev. 5 6/2003 MOTOROLA.COM/SEMICONDUCTORS

Freescale Semiconductor, Inc.

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

68HC12 Training Lab Student Exercise Book

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

Chapter 14. Motorola MC68HC11 Family MCU Architecture

INTERFACING THE ISCC TO THE AND 8086


Microprocessors/Microcontrollers

Lecture 15 February 20, 2012 Introduction to the MC9S12 Timer Subsystem What Happens when you Reset the MC9S12. Introduction to Interrupts

CMPEN 472 Sample EXAM II

Hardware Version 1.0 Monitor Version 1.2. English Release October

EB193. Motorola Semiconductor Engineering Bulletin. Replacing 68HC11A Series MCUs with 68HC11E Series MCUs. Freescale Semiconductor, I.

Introduction to Microcontrollers

Introduction to Embedded Systems

EEL 4744C: Microprocessor Applications. Lecture 7. Part 1. Interrupt. Dr. Tao Li 1

Reading Assignment. Interrupt. Interrupt. Interrupt. EEL 4744C: Microprocessor Applications. Lecture 7. Part 1

EE345L Fall 2008 Final Page 1 of 12

Z Z-280 MT8930, MT8992/3/4/5 MT8880 MT8888 MT8889 MT8980/1 MT8985, MT8986 (DIP-40) MT8986 (PLCC-44) MT8920B MT8952B

Using the stack and the stack pointer

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

1. Memory Mapped Systems 2. Adding Unsigned Numbers

Lab 2 Part 3 Assembly Language Programming and 9S12 Ports

Application Note. Interfacing the CS5525/6/9 to the 68HC05. By Keith Coffey MOSI (PD3) SDO MISO (PD2) SCLK. Figure 1. 3-Wire and 4-Wire Interfaces

ECE 571 Advanced Microprocessor-Based Design Lecture 3

AN1060. Motorola Semiconductor Application Note. M68HC11 Bootstrap Mode By Jim Sibigtroth, Mike Rhoades, and John Langan Austin, Texas.

Exam 1 Feb. 23, 25, 27?

ASSIGNMENT 3: PLAYING WITH THE 68HC11. Due Wednesday, Oct 9, 2002

Lecture 20: Interrupt Devices

a8255 Features General Description Programmable Peripheral Interface Adapter

MEMORY, OPERATING MODES, AND INTERRUPTS

Chapter 1. Microprocessor architecture ECE Dr. Mohamed Mahmoud.

Microcontrollers. Program organization Interrupt driven I/O. EECE 218 Microcontrollers 1

PARALLEL COMMUNICATIONS

INTERFACING THE ADS7870 AND THE MC68HC11E9 ANALOG TO MICROCOMPUTER MADE EASY

Module 2.F. Buffered, Interrupt-Driven Printer Design Example. Tim Rogers 2017

Add a Non-Volatile Clock to the MC68HC705J1A. Some applications of using the DS1307 are:

Embedded Applications. COMP595EA Lecture03 Hardware Architecture

AN1745. Interfacing the HC705C8A to an LCD Module By Mark Glenewinkel Consumer Systems Group Austin, Texas. Introduction

Menu Computer Organization Programming Model for the an example microprocessors (the G-CPU & Motorola 68HC11) Assembly Programming Look into my...

AN-HK-32. In-Circuit Programming of FLASH Memory in the MC68HC908GP32. nc... Freescale Semiconductor, I. PART 1 Introduction

Transcription:

EEL 4744C: Microprocessor Applications Lecture 6 Part 2 MC68HC12 Parallel I/O Dr. Tao Li 1

Software and Hardware Engineering (new version): Chapter 11 Or SHE (old version): Chapter 7 And Reading Assignment M68HC12 Data Sheet: Chapter 1 (1.6.8 - end), Chapter 5 and 6 Dr. Tao Li 2

Operating Modes (1) Selected by BKGD, MODA, MODB pins when RESET* is applied (total 8, special modes allow greater access to protected control registers) Normal single-chip mode All I/O and memory contained within device HC12B32: 32KB EEPROM, 1KB RAM Self-contained except for clock source and reset circuit Pros: external interfaces do not have to be designed Cons: RAM capacity is quite limited and may not fit large applications Dr. Tao Li 3

Programmer s I/O Model All I/O and control of I/O is performed using 512 control registers Initially mapped to addresses $0000-$01FF (but may be changed via writing to special register) Except for a few exceptions, most I/O ports require initialization before use via programming bits in the control registers Dr. Tao Li 4

HC12 Parallel I/O Ports I/O ports can be accessed just like memory (e.g. memory mapped I/O, can use various addressing modes REGS: EQU $0000; Register Base address PORTB: EQU $01 ; Offset to PORTB ; - - - ; Read Port B ldaa PORTB ; Direct Addressing ldx #REGS ldaa PORTB, x ; Indexed ldx VECTOR ldaa [0,x] ; Indexed-Indirect ; VECTOR: DC.W PORTB ; Address of PORTB Dr. Tao Li 5

HC12B32 Parallel I/O Ports Ports A and B used for I/O in single-chip mode, or multiplexed external address and data bus pins in expanded mode Port E used as 6 I/O lines plus IRQ* and XIRQ* interrupt pins in single-chip mode; control signals in expanded modes (more later) Port S used as 8 I/O lines (default), or one SCI (2 lines), one SPI (4 lines), and 2 I/O lines (more later) Port T used as 8 I/O lines (default) or 8 timer bits (more later) Port AD may be 8-bit input port (default) or used for 8 analog inputs to on-chip A/D converter (more later) Dr. Tao Li 6

HC12 Parallel I/O Ports Ports C, D, F, G, H, J are not available on HC12B32 (they may appear in the examples in the text book or lecture) Read SHE (old version) pp 169-179 to obtain basic information We will learn ports E, S, T, and AD as well as the corresponding control bits in great detail later Dr. Tao Li 7

Data Direction Registers Used to control input or output use of bits in a port (1=output, 0=input) When CPU reset, all registers (except a few such as in Port E) placed in input mode If port a mixture of input and output bits: Writing to port affects only those set as outputs Reading from port returns values on input bits as well as last value(s) on output bits Dr. Tao Li 8

Data Direction Registers Example PORTD: EQU 5 ; PORTD address DDRD: EQU 7 ; Data Direction Reg OBITS: EQU %11110000 ; Bits to be output ; - - - bset DDRD,OBITS ; Set direction register ; - - - ; Output data to bits 7-4 ldaa #%11110000 staa PORTD ; Read data on bits 3-0 ldaa PORTD Dr. Tao Li 9

Pull-up Control and Reduced Drive Good design practice to tie unused input pins to either logic-1 or logic-0 HC12 provides Pull-Up Control Register (PUCR) to enable pull-up resistors on any ports configured as inputs on reset, all pull-up resistors are enabled RDRIV (Reduced Drive of I/O Lines): reduce the drive level of output pins for power saving and lower RFI (disabled on reset) Dr. Tao Li 10

Writing HC12 I/O Software Initialization: set up the function of the ports and the direction of data flow Data input/output: read/write data Synchronization: Real-time synchronization (e.g. delay loop) Polled I/O Interrupt (more later) Dr. Tao Li 11

Polled I/O Example Dr. Tao Li 12

Polled I/O Assembly Code PORTJ: EQU $28 ; Port J address PORTH: EQU $24 ; Port H address DDRH: EQU $25 ; Port H data direction BIT0: EQU %00000001 BIT1: EQU %00000010 O_BITS: EQU %00001111 ; - - - ; Initialization ; Set up PORTH[3:0] to be output bset DDRH,O_BITS ; - - - ; Output data to Port H ; Wait until the status bit, Port J, Bit-0 is 1 SPIN1: brclr PORTJ,BIT0,SPIN1 ; Now can output the data ldaa data1 staa PORTH ; - - - ; Input data from Port H ; Wait until the status bit, Port J, Bit-1 is 1 SPIN2: brclr PORTJ,BIT1,SPIN2 ; Now can input the data ldaa PORTH staa ; - - - data1: DS 1 data2: DS 1 data2 Dr. Tao Li 13

Hardware Handshaking I/O No dedicated h/w for this use general-purpose I/O bits plus s/w similar to polling Unlike polling, handshaking goes both ways Dr. Tao Li 14

Hardware Handshaking I/O Example Dr. Tao Li 15

Handshaking I/O Assembly Code hskio1c.asm Assembled with CASM 05/24/1998 23:35 PAGE 1 0000 1 PORTJ: EQU $28 ; Port J address 0000 2 DDRJ: EQU $29 ; Data direction Port J 0000 3 PORTH: EQU $24 ; Port H address 0000 4 DDRH: EQU $25 ; Data direction Port H 0000 5 BIT0: EQU %00000001 0000 6 BIT1: EQU %00000010 0000 7 BIT2: EQU %00000100 0000 8 BIT3: EQU %00001000 0000 9 O_BITS: EQU %00001111 10 ; - - - 11 ; Initialization 0000 4C250F 12 bset DDRH,O_BITS ; Port H output 0003 4C290A 13 bset DDRJ,BIT1 BIT3 ; Port J-1,3 output 0006 4D280A 14 bclr PORTJ,BIT1 BIT3 ; Reset NEW_DATA_READY 0009 4D2808 15 bclr PORTJ,BIT3 ; READY_FOR_NEW_DATA 16 ; - - - 17 ; Handshaking output data to Port H 18 ; Wait until the status bit, Port J, Bit-0 is 1 000C 4F2801FC 19 SPIN1: brclr PORTJ,BIT0,SPIN1 20 ; Now can output the data 0010 B6002A 21 ldaa data1 0013 5A24 22 staa PORTH 23 ; and can strobe the handshaking bit 0015 4C2802 0018 4D2802 24 25 bset bclr PORTJ,BIT1 PORTJ,BIT1 26 ; - - - Dr. Tao Li 16

Handshaking I/O Assembly Code 27 ; Handshaking input data from Port H 28 ; Set READY_FOR_NEW_DATA on Port J, Bit-3 001B 4C2808 29 bset PORTJ,BIT3 30 ; Wait until the status bit, Port J, Bit-2 is 1 001E 4F2804FC 31 SPIN2: brclr PORTJ,BIT2,SPIN2 32 ; Now can input the data 0022 9624 33 ldaa PORTH 0024 7A002B 34 staa data2 35 ; and reset the READY_FOR_NEW_DATA 0027 4D2808 36 37 ; bclr PORTJ,BIT3 - - - 002A 38 data1: DS 1 002B 39 data2: DS 1 Dr. Tao Li 17

Operating Modes (2) Normal expanded-narrow & normal expandedwide modes In both forms of expanded mode, some I/O ports are used for creating a system bus On HC12B32 Ports A and B serve as pins for address bus (ADDR 0-15 ) Ports A (and B if wide mode) as pins for multiplexed data bus Ports E as pins for control bus (e.g. R/W*, E clk, LSTRB*) Dr. Tao Li 18

HC12B32 Expanded Modes Expanded mode provides address, data, and control buses at the expense of Ports A, B and some pins in Port E Dr. Tao Li 19

Memory Mapping in HC12B32 Expanded Modes Dr. Tao Li 20

Accessing External Memory and Ports in Expanded (Wide) Modes In expanded-wide mode, the B32 has a multiplexed 16-bit address and data bus With a 16-bit address bus, the B32 can access 2^16 = 65,536 bytes of data With a 16-bit data bus, the B32 can access 16 bits (two bytes) in a single bus cycle In expanded mode, the B32 uses Port A and Port B as the multiplexed address/data bus Dr. Tao Li 21

Accessing External Memory and Ports in Expanded (Wide) Modes Timing is controlled by the E clock When the E clock is low, the B32 places the address on the multiplexed bus Port A is used for address bits 15-8 Port B is used for address bits 7-0 When the E clock is high, the B32 uses the multiplexed bus for data bus Port A is used for D15-D8 [data for even (high) byte] Port B is used for D7-D0 [data for odd (low) byte] Dr. Tao Li 22

Accessing External Memory and Ports in Expanded (Wide) Modes Dr. Tao Li 23

Accessing External Memory and Ports in Expanded (Wide) Modes For example, if accessing the sixteen-bit word at address 0x4000 (the bytes at addresses 0x4000 and 0x4001) Port A will access the byte at address 0x4000 Port B will access the byte at address 0x4001 Note: The follow example is for illustration purpose. On HC12B32 expanded modes, external memory should be mapped between $8000 - $FFFF Dr. Tao Li 24

Accessing External Memory and Ports in Expanded (Wide) Modes To determine whether it should access one byte or two bytes, the B32 uses the LSTRB* and A0 lines LSTRB* low: accessing the lower (odd) byte of a word LSTRB* high: accessing the upper (even) byte of a word A0 low: accessing the upper (even) byte of a word A0 high: accessing the lower (odd) byte of a word Dr. Tao Li 25

Accessing External Memory and Ports in Expanded (Wide) Modes Aligned Misaligned ldaa $4000 Address on bus: A0: 0 LSTRB*: 1 ldaa $4001 Address on bus: A0: 1 LSTRB*: 0 ldd $4000 Address on bus: A0: 0 LSTRB*: 0 Dr. Tao Li 26

A Simple Parallel Input Port Create an input port at address 0x4000 (an even address, or high byte) Dr. Tao Li 27

A Simple Parallel Output Port Create an output port at address 0x4001 (an odd address, or low byte) Dr. Tao Li 28

An Output Port which can be Read Create an output port which can be read at address 0x4001 (an odd address, or low byte) Dr. Tao Li 29

A Parallel Input/Output Port Create a input/output port at address 0x4001 (an odd address, or low byte) Dr. Tao Li 30

Expanded Mode Memory Dr. Tao Li 31

Expanded-Narrow Mode Memory Dr. Tao Li 32

Expanded-Wide Mode Memory Dr. Tao Li 33