EE475 Lab #3 Fall Memory Placement and Interrupts

Similar documents
Viewing the tm4c123gh6pm_startup_ccs.c file, the first piece of code we see after the comments is shown in Figure 1.

Introduction to the IDE

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

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

Summer 2003 Lecture 14 07/02/03

Engineer To Engineer Note

ECE372 CodeWarrior Simulator Andreou/Michaelides

EE Embedded Systems Design. Lessons Exceptions - Resets and Interrupts

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

538 Lecture Notes Week 5

538 Lecture Notes Week 5

CSE3215 Embedded Systems Laboratory

EE4390 Microprocessors

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

Hands-On with STM32 MCU Francesco Conti

Lab 3-2: Exploring the Heap

Codewarrior for ColdFire (Eclipse) 10.0 Setup

ME 4447/6405 Introduction to Mechatronics Instructor: Professor Charles Ume

Part 1: Introduction to the C Language

Programming Book for 6809 Microprocessor Kit

Comparison of C and Assembly How to compile a C program using CodeWarrior

COMP 7860 Embedded Real- Time Systems: Threads

embos Real Time Operating System CPU & Compiler specifics for ARM core with ARM RealView Developer Suite 3.0 Document Rev. 1

RVDS 3.0 Introductory Tutorial

C Language Programming, Interrupts and Timer Hardware

Metrowerks CodeWarrior IDE 5.5 Tutorial

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

Lab 3-3: Scenario - Fixing a Memory Leak

Interrupts. How can we synchronize with a peripheral? Polling

Interrupt vectors for the 68HC912B32. The interrupt vectors for the MC9S12DP256 are located in memory from 0xFF80 to 0xFFFF.

Embedded Systems. 2. Software Development. Lothar Thiele. Computer Engineering and Networks Laboratory

HOW TO DIVIDE BOOT AND FLASH AREAS

C Language Programming, Interrupts and Timer Hardware

Lab 8 RS232 October 22, 2015

Interrupts & Interrupt Service Routines (ISRs)

ARM Assembler Workbook. CS160 Computer Organization Version 1.1 October 27 th, 2002 Revised Fall 2005

CET360 S12 DEMO PROGRAM #1 (C)

Bootloader project Project with a Bootloader Component and communication Component.

What happens when an HC12 gets in unmasked interrupt:

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

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

Interrupt Basics Karl-Ragmar Riemschneider

TMS470 ARM ABI Migration

Comparison of C and Assembly How to compile a C program using CodeWarrior

Lecture 03 Bits, Bytes and Data Types

Learning Objectives. A Meta Comment. Exercise 1. Contents. From CS61Wiki

Fundamentals of Programming Session 12

Note that FLIP is an Atmel program supplied by Crossware with Atmel s permission.

Real Time Embedded Systems. Lecture 10 January 31, 2012 Interrupts

Lecture 6: Assembly Programs

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

Computer Systems Lecture 9

COSC345 Software Engineering. Basic Computer Architecture and The Stack

Micrium OS Kernel Labs

Compiling Your Code and Running the Tests

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

XC2287M HOT. Solution ASC. Uses a timer triggered LED to toggle with ASC Interrupt

Program SoC using C Language

11 'e' 'x' 'e' 'm' 'p' 'l' 'i' 'f' 'i' 'e' 'd' bool equal(const unsigned char pstr[], const char *cstr) {

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ...

AN HI-3200 Avionics Data Management Engine Evaluation Board Software Guide

Laboratory Exercise 7

Objectives. ICT106 Fundamentals of Computer Systems Topic 8. Procedures, Calling and Exit conventions, Run-time Stack Ref: Irvine, Ch 5 & 8

Final Exam. Date: May 14, Printed Name:

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

Lab 8 The Stack (LIFO) Structure

Introduction to Mechatronics

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011

New Concepts. Lab 7 Using Arrays, an Introduction

CSC 1600 Memory Layout for Unix Processes"

Design UART Loopback with Interrupts

CMSC 412 Project 1: Keyboard and Screen Drivers

ENCM 369 Winter 2017 Lab 3 for the Week of January 30

embos Real Time Operating System CPU & Compiler specifics for RENESAS SH2A CPUs and KPIT GNU compiler Document Rev. 1

Bootloader project Project with a Bootloader component and communication component.

Investigating IO Interrupts

CS , Fall 2004 Exam 1

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.

Context Switching & Task Scheduling

AN4464 Application note

A Fast Review of C Essentials Part II

The HC11. Alexandra Carey & Richard Hughey. University of California, School of Engineering Santa Cruz, CA 95064

ECE 372 Microcontroller Design Parallel IO Ports - Interrupts. ECE 372 Microcontroller Design Parallel IO Ports - Interrupts

Exam 2 E2-1 Fall Name: Exam 2

Storage Class Specifiers Scope and Lifetime of Variables CMPE-013/L. Modules and Scope. Storage Class Specifiers Automatic Variables

BASICS OF THE RENESAS SYNERGY PLATFORM

Mechatronics Laboratory Assignment 2 Serial Communication DSP Time-Keeping, Visual Basic, LCD Screens, and Wireless Networks

ELEC 3040/3050 Lab Manual Lab 2 Revised 8/20/14. LAB 2: Developing and Debugging C Programs in MDK-ARM for the STM32L100RC Microcontroller

real-time kernel documentation

Interrupts L33-1. Interrupts

Windows Device Driver and API Reference Manual

M16C/26 APPLICATION NOTE. Measuring Computation Time of a Function Call. 1.0 Abstract. 2.0 Introduction. 3.0 Number of Function Call Returns

Pragma intrinsic and more

Lab Overview. Lab Details. ECEN 4613/5613 Embedded System Design Week #7 Fall 2006 Lab #3 10/08/2006

United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017

embos Real Time Operating System CPU & Compiler specifics for RENESAS SH2 CPUs and RENESAS HEW4 Document Rev. 1

Getting Started with the HCS12 IDE

Fredrick M. Cady. Assembly and С Programming forthefreescalehcs12 Microcontroller. шт.

MPATE-GE 2618: C Programming for Music Technology. Unit 4.1

Transcription:

EE475 Lab #3 Fall 2005 Memory Placement and Interrupts In this lab you will investigate the way in which the CodeWarrior compiler and linker interact to place your compiled code and data in the memory of the HC12 evaluation board. You will also install an interrupt function that is called when the IRQ button is pressed. Preliminaries 1. Make a temporary local folder for your work: c:\eeclasses\ee475\tempxxx. 2. Launch CodeWarrior and create a new project using the New Project Wizard (see Lab #2 if you don't recall the procedures). 3. Make (compile and link) a dummy main.c program (empty main() routine). 4. In CodeWarrior, open the linker input file, simulator_linker.prm. The.prm file tells the linker the regions of memory that are available. The ROM and RAM labels are defined and used to locate the program s code and data. From the simulator_linker.prm file, record the ROM and RAM address ranges and include this information in your memo report. 5. Now open the linker output map file, simulator.map. The.map file is generated by the linker, and lists the results of the linking process, i.e., where the code and data segments were placed in the HC12 memory. For this minimal C program note that the program occupies only a few dozen bytes, and there are no constants and no static data. Exercise #1: Now see what happens to the actual memory allocation when you declare an array in various ways: automatic, static, automatic initialized, static initialized, and global. Do this by making the following modifications to your C program: 1. Edit your C program by adding the statements within the main() block: char buf[40]; buf[0]='\0'; This creates an automatic storage class array and simply sticks a null in it. Build the program, open the simulator.map file, find the SECTION-ALLOCATION SECTION and fill out the first column of the table on the check-off sheet, indicating the size of each of the specified segments. If the

EE475 Lab #3 2 segment is not present, just leave that box blank. Ignore the.abs_section lines. 2. Now edit your C program to change the declaration to be initialized: char buf[40]={"test"}; Rebuild and note the size of each segment from the linker output file in column 2 of the table. 3. Again edit your C program to change the declaration to static, without initializing: static char buf[40]; buf[0]='\0'; Rebuild and note the size of each segment in column 3. 4. Once again edit your program to use a static initialized array: static char buf[40]={"test"}; Rebuild and note the size of each segment in column 4 of the table. 5. Finally, make the buf array declaration global by moving it up outside of the main() function, i.e., char buf[40]; void main(void) { Rebuild and record the size of each segment in column 5. Using the.map file information, demonstrate for the instructor that you can locate each section and view the memory contents using the debugger. Note that the memory requirements and linker behavior differ depending on the class of storage used. 1. If the buffer is automatic and uninitialized, it will only appear on the stack and no memory is allocated explicitly in the program.

EE475 Lab #3 3 2. If the buffer is automatic but must be initialized, the code image now must include the initialization string AND some additional instructions that will copy the initialization string into the buffer (on the stack) before it is used. 3. If the storage class is static, the buffer is placed in a static data segment. 4. Finally, if the buffer is declared global, the linker places it in a global memory segment. Be sure to explain your observations in your memo report. Does the contents of you table match these expectations? Which segments contain code (machine instructions) and which contain data? Verify your results and explain. Exercise #2: Replace the main.c file in your project with the main.c from Lab #2 (LED flash program). Make the program, fix any errors, and launch the debugger. Set the debugger to use the P&E target interface, and verify that the code runs properly (LEDs flash) on the HC12 evaluation board. Once everything is running properly, go back and modify your C program to include an interrupt function, as follows. To do this you will have to define an interrupt service routine (ISR) by using the type qualifier interrupt. This is done as follows: interrupt num void your_function_name(void) { your ISR code } The interrupt qualifier is important: it tells the compiler to generate an RTI (return from interrupt) at the end of the function, rather than an RTS (return from subroutine). The num indicates which interrupt vector number will be loaded with the address of your interrupt handler. Write the interrupt function so that it just increments a global variable. Something like: int vcnt; interrupt num void your_function_name(void) { vcnt++; } We want to install this interrupt service routine so that it gets executed when the user presses switch 1 (SW1) on the processor daughterboard. The button press generates the XIRQ signal, which is level sensitive. You need to determine which vector number (0, 1,

EE475 Lab #3 4 2, etc.) is associated with the XIRQ signal on the HC12. The vector number replaces num in the interrupt function declaration. Keep in mind that after your program sets the interrupt vector to point to your function, you will need to enable (unmask) the XIRQ interrupt signal using the X bit in the condition code register: _asm( andcc #BF ). Once enabled, XIRQ is unmaskable, but for other interrupts on the HC12 you need to do an interrupt enable using the statement EnableInterrupts; in your main() program. Make and load your program, then use the debugger to observe the vcnt variable before and after you press the IRQ button on the I/O board. Is the variable incremented? Show the instructor where the XIRQ vector address is located in the interrupt vector table. Also, show that the contents of that vector is the address of your_function_name(). Give your answers in hexadecimal. Exercise #3: (3a) Investigate what happens if you enable XIRQ but you do not install the interrupt service routine. In other words, where does the program jump to if no vector address has been installed? (3b) Finally, modify the LED flashing loop in your main() routine so that it stops looping (and thus stops flashing) once the XIRQ button has been pressed. NOTE that you should put a statement after the loop to prevent your main() program from exiting. An infinite loop is a good example. What happens if you do exit from the main() routine?? Is there an instruction that you can put in your program to halt execution and return control to the debugger just as if you had pressed the red stop button?

Instructor Verification Sheet Lab #3 Fall 2005 Student Name: SECTION-ALLOCATION SECTION segment sizes in bytes and start address in hex: Section Name (.map file) 1 auto 2 auto+init 3 static 4 static+init 5 global.text.bss.data.startdata.init.common.stack.copy #1 Locate and view segments in memory according to.map file. #2 Demonstrate functioning interrupt service routine and vector table entry. Instructor Initials Date