ELN5622 Embedded Systems Class 3 Spring, 2003 Kent Orthner

Slides:



Advertisements
Similar presentations
Computer Architecture
Advertisements

MC68HC11 System Overview. System block diagram (A8 version)
Interrupts Chapter 8 – pp Chapter 10 – pp Appendix A – pp 537 &
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
A look at interrupts What are interrupts and why are they needed.
Chapter 2 HARDWARE SUMMARY
8051 Core Specification.
I/O Unit.
Processor System Architecture
1 I/O and Interrupts Today: First Hour: I/O Concepts –Section of Huang’s Textbook –In-class Activity #1 Second Hour: Interrupt Code Example –In-class.
ELEC 330 Digital Systems Engineering Dr. Ron Hayne
68HC11 Polling and Interrupts
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
A look at interrupts What are interrupts and why are they needed in an embedded system? Equally as important – how are these ideas handled on the Blackfin.
CSS 372 Lecture 1 Course Overview: CSS 372 Web page Syllabus Lab Ettiquette Lab Report Format Review of CSS 371: Simple Computer Architecture Traps Interrupts.
ECE200 – Computer Organization Chapter 8 – Interfacing Processors and Peripherals.
Basic Input/Output Operations
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ input/output and clock inputs Sequence of control signal combinations.
Computer System Organization S H Srinivasan
A look at interrupts What are interrupts and why are they needed.
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
State Machines Timing Computer Bus Computer Performance Instruction Set Architectures RISC / CISC Machines.
Coordinate Based Tracking System
CSS 372 Oct 2 nd - Lecture 2 Review of CSS 371: Simple Computer Architecture Chapter 3 – Connecting Computer Components with Buses Typical Bus Structure.
1 ECE 263 Embedded System Design Lessons 2, 3 68HC12 Hardware Overview, Subsystems, and memory System.
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
Overview von Neumann Model Components of a Computer Some Computer Organization Models The Computer Bus An Example Organization: The LC-3.
Midterm Wednesday 11/19 Overview: 25% First Midterm material - Number/character representation and conversion, number arithmetic - DeMorgan’s Law, Combinational.
INTERRUPTS PROGRAMMING
The 8051 Microcontroller architecture
1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.
ECE 265 – LECTURE 12 The Hardware Interface 8/22/ ECE265.
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
Revised: Aug 1, ECE 263 Embedded System Design Lessons 23, 24 - Exceptions - Resets and Interrupts.
MICROPROCESSOR INPUT/OUTPUT
(More) Interfacing concepts. Introduction Overview of I/O operations Programmed I/O – Standard I/O – Memory Mapped I/O Device synchronization Readings:
Interrupts and reset operations. Overview  Introduction to interrupts – What are they – How are they used  68HC11 interrupt mechanisms – Types of interrupts.
ELE22MIC Lecture 8 ASll Examples –16 Bit Counters –Buffalo Jump Table Interrupt processing (IRQ/RTI) Stack Frame & Base Pointer Wired OR.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
1 Interrupts, Resets Today: First Hour: Interrupts –Section 5.2 of Huang’s Textbook –In-class Activity #1 Second Hour: More Interrupts Section 5.2 of Huang’s.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Intel 8051 Another family of microcontroller is the Intel 8051 family. The basic 8051 microcontroller has four parallel input/output ports, port 0, 1,
PPI-8255.
Processor Structure and Function Chapter8:. CPU Structure  CPU must:  Fetch instructions –Read instruction from memory  Interpret instructions –Instruction.
System Integration Module MTT Motoola SYSTEM INTEGRATION MODULE (SIM)
Parallel I/O. Introduction This section focuses on performing parallel input and output operations on the 68HC11 3 operation types – Simple, blind data.
Presented by Sadhish Prabhu
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
بسم الله الرحمن الرحيم MEMORY AND I/O.
1 Bringing it all together: Exploring the EVB Today: First Hour: Bringing it all together by exploring the EVB –Section of Huang’s Textbook.
1 Basic Processor Architecture. 2 Building Blocks of Processor Systems CPU.
Embedded Systems Lecture 5 January 25 th, 2016.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
1 Bringing it all together: Exploring the EVB Today: First Hour: Bringing it all together by exploring the EVB –Section of Huang’s Textbook.
80C51 Block Diagram 1. 80C51 Memory Memory The data width is 8 bits Registers are 8 bits Addresses are 8 bits – i.e. addresses for only 256.
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ read/write and clock inputs Sequence of control signal combinations.
DEPARTMENT OF ELECTRONICS ENGINEERING V-SEMESTER MICROPROCESSOR & MICROCONTROLLER 1 CHAPTER NO microcontroller & programming.
Seminar On 8085 microprocessor
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
COURSE OUTCOMES OF Microprocessor and programming
CS501 Advanced Computer Architecture
68HC11 Interrupts & Resets.
Introduction of microprocessor
ECET 330 Innovative Education--snaptutorial.com
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Computer Operation 6/22/2019.
Presentation transcript:

ELN5622 Embedded Systems Class 3 Spring, 2003 Kent Orthner

Assembly Language Programming

 Conventions: –Rules that a designer follows to make his/her program easier to understand, communicate to other, debug, and less prone to mistakes.  Includes: –Comment conventions –Naming conventions –Drawing Conventions Programming Conventions

 Program Header –What the program does –Author’s Name –File Name –Date –Version –History  Function Header –What the function does/How it works –Author’s Name –Date –History Assembly Language Style

 Equates vs. In-line constants –Use constants wherever possible –Easier to understand, –Easier to fix –Easier to maintain  Location of Equate Statements –All together –Point-of-use Assembly Language Style

 Types of Equates –System Equates System Functions Location of I/O Registers Port Addresses –Constant Equates CR/LF, End of String, NIL –Memory Map Equates Program Location Flash Memory Location Stack Pointer Location Assembly Language Style

 Constant Data Definitions –Tables, Strings, Etc. –Located in ROM –Often best to have at the end of the program to lessen the chance of them executed  Variable Data Definitions –System-wide Variables –Located in RAM  Non-volatile ROM Data –Database for user settings –Maintained when power is shut off Assembly Language Style

 Indenting –Not commonly used for assembly programs –Can ease understanding by making program flow more obvious. –Up to the individual designer.  Use ‘Boilerplate’ files –All files use the same flow –Saves Typing –Less potential Mistakes Assembly Language Style

 Commenting Style –Headers for functional blocks –Headers per line –Goal: To make it so the person maintaining the code can understand the program. Assembly Language Style

 Naming Conventions –Very important to prevent errors and make code easy to understand. –Examples: LDX SP LDB X,p_operandStack variable LDA g_timerGlobal variable JSR s_timercheckSubroutine LDB X,OperandStack variable LDA G_TimerVarGlobal variable JSR TIMERCHECK Subroutine Assembly Language Style

 Pseudocode –Self-commenting, less prone to error –Makes it natural to 1.design first with pseudo code 2.Implement second with assembly language * Get Temp * If Temp > MaxAllowed * Turn valve off * Else * turn the valve on * End if Assembly Language Style

 Pseudocode * Get Temp LDAA TEMP_PORT * If Temp > MaxAllowed IF_TEMPMAX: CMPA MaxAllowed A-MaxAllowed BLE EL_TEMPMAX Branch if <= 0 * Turn valve off LDAA ValveOff STAA CONTROL_PORT BRA EI_TEMPMAX * Else turn the valve on EL_TEMPMAX: LDAA ValveOn STAA CONTROL_PORT * End if EI_TEMPMAX: Assembly Language Style

 While-Do Loop * While Temperatue > MaxAllowed WH_MAXALL: CMPA MaxAllowed A-MaxAllowed BLS EW_MAXALL Branch if < 0 * Do * End While BRA WH_MAXALL EW_MAXALL: Assembly Language Style

 Repeat-Until Loop * Repeat RP_SWSTATE: * Until SwitchState = END_STATE LDAA SwitchState CMPA END_STATE BNE RP_SWSTATE Assembly Language Style

 For Loop * For (I=COUNT, I--, I==0) LDAACOUNT * Begin FOR_LOOP: PUSH A... * Next PULA DECA BNE FOR_LOOP Assembly Language Style

Anatomy of an Embedded Program

Embedded System Characteristics  A computing system embedded within a device.  A system intended for a single purpose, which includes a general purpose processor.  Often used for –providing user control over a product –to observe or control something in the “real world” (i.e. analog)

Embedded System Startup  What is the first thing the user expects when an embedded system starts up? –Begin application execution.  When should the software in an embedded system finish? –It shouldn't. It should (normally) run until the power is turned off.

 Environment setup –System Equates –Constant Equates –Memory Map Equates  Initialization –Set stack pointer –Special Register Setup –Initialize Tasks –Enable Interrupts  Main Loop –Execute Applications Embedded Program Flow

Initialize Stack Pointer Special Register Setup Initialize Task 1 Initialize Task 2 Enable Interrupts. ( Go! ) Initialize Task 3 Execute Task 1 Execute Task 2 Execute Task 3

Environment Setup  Types of Equates –System Equates System Functions Location of I/O Registers Port Addresses –Constant Equates CR/LF, End of String, NIL –Memory Map Equates Program Location Flash Memory Location Stack Pointer Location

 68HC11 jumps to the 'Reset Vector' located at 0xFFFE, 0xFFFF PC <- M(0xFFFE, 0xFFFF) Execution Start

 Initialize Stack Pointer –Interrupts –Functions –Temporary Storage  Special Register Setup –Memory Mapping registers Determine the location of RAM & the register block within the memory map. Can only be written at Startup Initialization

 Special Register Setup (Continued) –System Configuration Registers A/D Powerup Clock Select IRQE Edge-Sensitive Select Clock Monitor Enable COP Timer Rate –I/O Control Registers –Timer Registers –Interrupt Mask Registers –SCI & SPI Registers –ADC/DAC Control Registers Initialization

 Task Initializatoin –Set initial state for state machines –Set initial values for task variables –Pre-compute tables where necessary –Clear / pre-set buffers Initialization

Main Loop Architecture  3 buttons need to be checked at least 10 times a second: repeat for (i=2; i--; i==0) Checkbutton(i); end for until ( false )

Main Loop Architecture  3 buttons need to be checked at least 10 times a second, and 3 pins must be set 5 times a second. repeat for (i=2; i--; i==0) CheckButton(i); end for if (FifthSecondIsUp) for (i=2; i<3; i--) SetPin(i); end for end if until ( false )

Main Loop Architecture  3 buttons need to be checked at least 10 times a second, and 3 pins must be set 5 times a second. repeat for (i=2; i--; i==0) CheckButton(i); end for if (FifthSecondIsUp) for (i=2; i<3; i--) SetPin(i); end for end if until ( false )

Main Loop Architecture  And if there are a couple more things to be done, all at different times … repeat CheckButtons() SetPins() ControlMotors() SetDisplay() until ( false )

Cyclical Executive  Architecture Repeat Task1 () Task2 () Task3 () Until ( false )

Cyclical Executive  Architecture * Repeat MAINLOOP: * Task1 () JSR TASK1 * Task2 () JSR TASK2 * Task3 () JSR TASK3 * Until ( false ) JMP MAINLOOP

Cyclical Executive  Adequate for simple applications.  Other Names: –Round Robin Executive –Round Robin Kernel –Super Loop  Rules: –Tasks may not employ busy waiting –Tasks must do their work quickly and return to the main loop so that other tasks can run –Tasks must save their place by using a state variable

Cyclical Executive  Advantages: –Small –Compact –Easy to use –Easy to understand  Disadvantages –No priorities –Polls for events –Timing responsibility is put on the programmer

68HC11 On-Chip Peripherals: Parallel I/O

Parallel I/O  Three Functions per pins: –Output (1 or 0) –Wired-or output (1 or 0) –Input  Up to 40 I/O pins.  Each pin can be used as I/O or another function.  Some pins are fixed-direction, some are bidirectional.

Parallel I/O  Port A –Shared with Timer & Pulse Accumulator –PA7:Bidir –PA6-PA3: Output Only –PA2-PA0 : Input Only  Port B –Shared as Expanded bus Address pins –Output Only  Port C –Shared as Expanded bus Data / Multiplexed Address pin. –Bidirectional

Parallel I/O Registers  PORTn –8-bit register for each port –Reads return the level of the pin itself for input/bidirectional pins, or the state of the logic inside the output buffer at the pin output. –Writes cause the data to be latched, so it can be used for output operation. (not input pins.)  PORTCL –Special Port C register for handshake writes.

Parallel I/O Registers  DDRn –Register for each bidirectional pin. –Controls the direction of data flow. 0 = Input 1 = Output –Subsystem function overrides this pin function Ie. SCI Tx/Rx  Control Registers –Determine if the pin is going to be used as General Purpose I/O, or as a subsystem pin. –Determines if an output will be a wired-or (open collector) output.

Handshaking  Ports B&C, with STRA input & STRB output  3 modes: –Simple Strobe (default) Port B = Simple Strobe Output Port C = Simple Strobe Input –Full-input Handshake –Full-output Handshake  Configured with PIOC register

Handshaking - Simple Mode  Port B: Output with STAB  Port C: Input with STAA

Handshaking - Full-Input Handshake  Port C: Input with both STAA & STAB

Handshaking - Full-Output Handshake  Port C: Output with both STAA & STAB