ECE 367 -Experiment #1 Fall 2012

Similar documents
ECE 3120: Computer Systems Chapter 8: ECE-3120-A Musical

538 Lecture Notes Week 5

538 Lecture Notes Week 5

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

Coe538 Final Study Guide 2016 (Questions & Answers)

Experiment 2 Fall 2012

HC12 Built-In Hardware

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

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

Lab 2 Part 3 Assembly Language Programming and 9S12 Ports

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

Introduction to the MC9S12 Hardware Subsystems

EE 308 Spring A software delay

CMPEN 472 Sample EXAM II

Capstone Design Course. Lecture-2: The Timer

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

Experiment 6 Fall 2012

Mark II Aiken Relay Calculator

C Language Programming, Interrupts and Timer Hardware

Programming the Motorola MC68HC11 Microcontroller

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

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

ECE/CE 3720: Embedded System Design

Lab 9: On-Board Time Generation and Interrupts

ECE3120: Computer Systems Chapter 7: Interfacing I/O Devices Lab-Class

C Language Programming, Interrupts and Timer Hardware

68HC11 Opera,ng Modes

EE319 K Lecture 7. Address mode review Assembler, Debugging Psuedo ops 16 bit timer finite state machines. University of Texas ECE

Homework 3 Aid Understanding Homework 2/3 Program

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

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

Quick Guide to Using Code Warrior

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

EE 308 Spring Hello, World!

Lecture 20: Interrupt Devices

Using the stack and the stack pointer

Sample Problem Set #1

Programming Adapt9S12E128 and NC12 with using ubug12

AN Kbyte Addressing with the M68HC11. Overview

Lecture 9 Subroutines

It translates (converts) assembly language to machine code.

Chapter 2: HCS12 Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh

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

ECE331 Handout 3- ASM Instructions, Address Modes and Directives

Introduction to Microcontrollers III

How to use CodeWarrior ASM with Adapt9S12 and Serial Monitor.doc

Interrupt and Timer ISRs. Student's name & ID: Partner's name(s) & ID(s): Your Section number & TA's name

Immediate vs. Extended mode: Immediate values are marked with a # symbol. They also are different instructions when assembled.

C SC 230 Computer Architecture and Assembly Language April 2000 Exam Sample Solutions

Introduction to the 9S12 Microcontroller

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

Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory

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

What Happens When You Reset the MC9S12?

MC9S12 Assembler Directives A Summary of MC9S12 Instructions Disassembly of MC9S12 op codes. Summary of HCS12 addressing modes ADDRESSING MODES

Chapter 4: Advanced Assembly Programming. EE383: Introduction to Embedded Systems University of Kentucky. Samir Rawashdeh

538 Lecture Notes Week 3

MC68HC12 Parallel I/O

ECE 3120 Fall 2013 Lab 1 Code Entry, Assembly, and Execution

ECE 3120 Lab 1 Code Entry, Assembly, and Execution

538 Lecture Notes Week 1

Introduction to Microcontrollers III

CS/ECE 5780/6780: Embedded System Design

; export symbols ; export 'Entry' symbol. ; include derivative specific macros PORTA EQU $0000 PORTB EQU $0001 DDRA EQU $0002 DDRB EQU $0003

Lecture #4 Microcontroller Instruction Set Embedded System Engineering Philip Koopman Monday, 25-Jan-2016

ECE 3610 MICROPROCESSING SYSTEMS

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

Lecture 10 I/O and Interrupts

2. Arithmetic Instructions addition, subtraction, multiplication, divison (HCS12 Core Users Guide, Sections 4.3.4, and ).

EE 3170 Microcontroller Applications

Lecture 7 Assembly Programming: Shift & Logical

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

68HC12 Training Lab Student Exercise Book

; export symbols XDEF Entry ; export 'Entry' symbol ABSENTRY Entry ; for assembly entry point

COSC345 Software Engineering. Basic Computer Architecture and The Stack

Exam 1 Feb. 23, 25, 27?

ECE372 CodeWarrior Simulator Andreou/Michaelides

Wed. Sept 6 Announcements

Microcontrollers. 2IN60: Real-time Architectures (for automotive systems) Mike Holenderski,

Programming Book for 6809 Microprocessor Kit

Cross Assembly and Program Development

Lab 2 Part 1 Assembly Language Programming and 9S12 Ports

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

ECE/CS 5780/6780: Embedded System Design

General Features of Interrupts. ECE/CS 5780/6780: Embedded System Design. Stack Before and After an Interrupt. Sequence of Events During Interrupt

Interrupt and Timer ISRs. Student's name & ID (1): Partner's name & ID (2): Your Section number & TA's name

The Motorola 68HC11 Instruc5on Set

UNIVERSITY OF MANITOBA DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING. Term Test #2 Solution ECE 3610 MICROPROCESSING SYSTEMS

Timing Generation and Measurements

EE319K Final Fall 2005 Solution C. (3) Question 1. (3) Question 2. short function(const short in){ return in+5; } const

MC9S12 Address Space

Introduction to Programming the 9S12 in C Huang Sections 5.2 and 5.3. You will be able to use all of the Motorola data manuals on the exam.

CS/ECE 5780/6780: Embedded System Design

538 Lecture Notes Week 2

0b) [2] Can you name 2 people form technical support services (stockroom)?

SEVEN SEGMENT DISPLAY LAB EXPERIMENT

1. Memory Mapped Systems 2. Adding Unsigned Numbers

Computer Organization I. Lecture 28: Architecture of M68HC11

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

Interrupts. How can we synchronize with a peripheral? Polling

Transcription:

Due at the beginning of lab during week 3 (9/1/2012) Introduction ECE 367 -Experiment #1 Fall 2012 The goal of this experiment is the acquaint you with the Technological Arts nanocore12 microcontroller development system, and the procedures used to assemble/download/execute code on this processor. Specifically, you will do what is needed to have the microcontroller independently execute code that blinks some LED's. To do this you will need to install a program on a Windows PC and have access to its serial port. Required Hardware and Software 1. nanocore starter kit (UIC2) from Technological Arts 2. USB cable from Technological Arts 3. FreeScale CodeWarrior Special Edition: CodeWarrior for HCS12(X) Microcontrollers (Classic) (Rev 5.1) Go here to get it as explained in lab. Procedure 1. Install the Codewarrior program. 2. Run CodeWarrior IDE and choose Getting Started Tutorial - Absolute Assembly Tutorial 3. Read the Quick Start Guide. Then follow the guide instructions to assemble and power the system. Do not load the suggested software. 4. Build the circuit in Figure 1. below. 1/4

Figure 1. You are attaching LED's with current limiting resistors to three pins of PortT. The resistors should be 470 Ohms or 1K. 5. Using CodeWarrior, assemble the counter code that is provided for you in the Appendix below. You may copy and paste from between the -- cut here -- symbols. Be sure to delete "pre" and "/pre" html tags. Save the code as exp1.asm By assembling the program, (using the Make option) an executable code having *.s19 extension should have been created> 6. Next, use the Dubug feature to load and test the code. To do this FIRST move the RUN/LOAD switch to LOAD and ground the RESET pin momentarily then run (click on) debug. 7. When the code is successfully downloaded move the switch on the controller from the LOAD position to the RUN position and Ground the RESET pin momentarily. The program should run and the LED's will appear to be a threebit counter counting at one second intervals. 8. Congratulations! You now have a stand-alone computer that performs a simple function. Inspect the code and change the software delay loop constant LDY #0010 to LDY #0005. How does this affect the LED blinking rate? 2/4

Experiment 1 -Appendix: Three Bit LED Counter 68HC9S12 assembly language code -- cut here -- University of Illinois at Chicago, Dept. of Electrical and Computer Engineering ECE 367 -Microprocessor-Based Design Three Bit Counter Version 2, Aug 27, 2011 By Robert A. Becker PAY ATTENTION TO THE ALIGNMENT BELOW Labels start in the first column (left most column = colunm 1) OP CODES are at column 9 COMMENTS follow a "" symbol Blank lines are allowed (Makes the code more readable) Define symbolic constants PortT EQU $240 Define Register Locations DDRT EQU $242 INITRG EQU $11 INITRM EQU $10 CLKSEL EQU $39 PLLCTL EQU $3A CRGFLG EQU $37 SYNR EQU $34 REFDV EQU $35 COPCTL EQU $3C TSCR1 EQU $46 TSCR2 EQU $4D TIOS EQU $40 TCNT EQU $44 TC0 EQU $50 TFLG1 EQU $4E The ORG statment below would normally be followed by variable definitions There are no variables needed for this project. THIS IS THE BEGINNING SETUP CODE ORG $3800 Beginning of RAM for Variables The main code begins here. Note the START Label ORG $4000 Beginning of Flash EEPROM START LDS #$3FCE Top of the Stack SEI Turn Off Interrupts MOVB #$00, INITRG I/O and Control Registers Start at $0000 MOVB #$39, INITRM RAM ends at $3FFF We Need To Set Up The PLL So that the E-Clock = 24MHz BCLR CLKSEL,$80 disengage PLL from system BSET PLLCTL,$40 turn on PLL MOVB #$2,SYNR set PLL multiplier MOVB #$0,REFDV set PLL divider NOP No OP NOP NO OP PLP BRCLR CRGFLG,$08,PLP while (!(crg.crgflg.bit.lock==1)) BSET CLKSEL,$80 engage PLL 3/4

CLI Turn ON Interrupts End of setup code. You will always need the above setup code for every experiment LDAA #$FF Make PortT Outbound STAA DDRT LDAA #$00 Start the count at 0 AG: STAA PortT Output the count to PortT JSR DELAY Let's go wait one second INCA Increment the count BNE AG Do again unless the count > 255 STAA PortT If we get here the output will go blank BRA * Stop the program (Branch here forever) We use some built-in timer functions to create an accurate delay DELAY PSHA Save accumulator A on the stack LDY #10 We will repeat this subroutine 10 times MOVB #$90,TSCR1 enable TCNT & fast flags clear MOVB #$06,TSCR2 configure prescale factor to 64 MOVB #$01,TIOS enable OC0 LDD TCNT Get current TCNT value AGAIN ADDD #37500 start an output compare operation STD TC0 with 100 ms time delay WAIT BRCLR TFLG1,$01,WAIT Wait for TCNT to catch up LDD TC0 Get the value in TC0 DBNE Y,AGAIN 10 X 100ms = 1 sec PULA Pull A RTS End of counter code Define Power-On Reset Interrupt Vector AGAIN - OP CODES are at column 9 ORG $FFFE $FFFE, $FFFF = Power-On Reset Int. Vector Location FDB START Specify instruction to execute on power up End of Interrupt code END (Optional) End of source code -- cut here -- Last modified: Thur Jan 5 01:01:08 2012 4/4

ECE 367: Experiment 1 Semester: Fall 2012 Name: Kai Zhao UIN: 670720413 Due Date: 2012 Sept 11 Lab Section: T11 TA: Chenjie Tang

C:\Users\Tommy\Documents\ECE 367 Project 1\Sources\main.asm Wednesday, September 19, 2012 / 5:19 AM Page: 1 1: University of Illinois at Chicago, Dept. of Electrical and Computer Engineering 2: ECE 367 -Microprocessor-Based Design 3: Three Bit Counter 4: Version 2, Sept 11, 2012 5: By Kai Zhao 6: 7: PAY ATTENTION TO THE ALIGNMENT BELOW 8: Labels start in the first column (left most column = colunm 1) 9: OP CODES are at column 9 10: COMMENTS follow a "" symbol 11: Blank lines are allowed (Makes the code more readable) 12: 13: Define symbolic constants 14: PortT EQU $240 Define Register Locations 15: DDRT EQU $242 16: INITRG EQU $11 17: INITRM EQU $10 18: CLKSEL EQU $39 19: PLLCTL EQU $3A 20: CRGFLG EQU $37 21: SYNR EQU $34 22: REFDV EQU $35 23: COPCTL EQU $3C 24: TSCR1 EQU $46 25: TSCR2 EQU $4D 26: TIOS EQU $40 27: TCNT EQU $44 28: TC0 EQU $50 29: TFLG1 EQU $4E 30: 31: The ORG statment below would normally be followed by variable definitions 32: There are no variables needed for this project. 33: THIS IS THE BEGINNING SETUP CODE 34: 35: ORG $3800 Beginning of RAM for Variables 36: 37: The main code begins here. Note the START Label 38: 39: ORG $4000 Beginning of Flash EEPROM 40: START LDS #$3FCE Top of the Stack 41: SEI Turn Off Interrupts 42: MOVB #$00, INITRG I/O and Control Registers Start at $0000 43: MOVB #$39, INITRM RAM ends at $3FFF 44: 45: We Need To Set Up The PLL So that the E-Clock = 24MHz 46: 47: BCLR CLKSEL,$80 disengage PLL from system 48: BSET PLLCTL,$40 turn on PLL 49: MOVB #$2,SYNR set PLL multiplier 50: MOVB #$0,REFDV set PLL divider 51: NOP No OP 52: NOP NO OP 53: PLP BRCLR CRGFLG,$08,PLP while (!(crg.crgflg.bit.lock==1)) 54: BSET CLKSEL,$80 engage PLL 55: 56: 57: 58: CLI Turn ON Interrupts 59: 60: End of setup code. You will always need the above setup code for every experiment 61: 62: LDAA #$FF Make PortT Outbound 63: STAA DDRT 64: LDAA #$00 Start the count at 0 65: AG: STAA PortT Output the count to PortT 66: JSR DELAY Let's go wait one second 67: INCA Increment the count 68: BNE AG Do again unless the count > 255 69: STAA PortT If we get here the output will go blank 70: BRA * Stop the program (Branch here forever) 71: 72: We use some built-in timer functions to create an accurate delay 73: 74: DELAY PSHA Save accumulator A on the stack 75: LDY #10 We will repeat this subroutine 10 times 76: MOVB #$90,TSCR1 enable TCNT & fast flags clear 77: MOVB #$06,TSCR2 configure prescale factor to 64 78: MOVB #$01,TIOS enable OC0

C:\Users\Tommy\Documents\ECE 367 Project 1\Sources\main.asm Wednesday, September 19, 2012 / 5:19 AM Page: 2 79: LDD TCNT Get current TCNT value 80: AGAIN ADDD #37500 start an output compare operation 81: STD TC0 with 100 ms time delay 82: WAIT BRCLR TFLG1,$01,WAIT Wait for TCNT to catch up 83: LDD TC0 Get the value in TC0 84: DBNE Y,AGAIN 10 X 100ms = 1 sec 85: PULA Pull A 86: RTS 87: 88: End of counter code 89: 90: Define Power-On Reset Interrupt Vector 91: 92: AGAIN - OP CODES are at column 9 93: 94: ORG $FFFE $FFFE, $FFFF = Power-On Reset Int. Vector Location 95: FDB START Specify instruction to execute on power up 96: 97: End of Interrupt code 98: 99: END (Optional) End of source code