U of U ECE 3720 - Software Development
Pages 6

Unformatted text preview:

Slide 1'&$%ECE/CE 3720: Embedded System DesignChris J. MyersLecture 4: Software Development (cont)Slide 2'&$%Reasons for Object-Oriented in PC Domain1. We need a common user interface on top of a multitudeof similar but not identical computers.2. The hardware platform makes a fundamentaladvancement every 6 months.3. Many companies act in concert to produce a product.4. The newer software must run on the older computers.5. The older software must run on the newer computers.6. Hardware/software configuration may change at run time.1Slide 3'&$%Object-Oriented in the Embedded Space1. It is useful for embedded software to run on multiplemicrocomputers (i.e., code reuse).2. Embedded microcomputers have a much longer lifetimethan an x86 microprocessor.3. Usually single company develops hardware and software.4. Hardware and software are upgraded together.5. Hardware and software are upgraded together.6. Configurations are usually well-defined at compile time.• Still object-oriented does help portability and inproviding a good hardware abstraction layer.Slide 4'&$%Threads2Slide 5'&$%Interrupts and ThreadsSlide 6'&$%Recursion• A program segment is reentrant if it can be concurrentlyexecuted by two (or more) threads.• A recursive program is one that calls itself.• When we draw a calling graph, a circle is formed.• Recursive subroutines must be reentrant.• Often easy to prove correct and use less permanentmemory, but use more stack space and are slower.void OutUDec(unsigned int number){if (number>=10){OutUDec(number/10);OutUDec(number%10); }elseOutChar(number+’0’); }3Slide 7'&$%Basic Concepts of Device Drivers• A device driver consists of software routines that providethe functionality of an I/O device.• Includes interface routines and low-level routines forconfiguring the device and performing actual I/O.• Separation of policy and mechanism is very important.• Interface may include routines to open, read, and writefiles, but should not care what device the files reside on.• Require a good hardware abstraction layer (HAL).• Low-level device drivers normally found in basic I/Osystem (BIOS) ROM and have direct access to hardware.Slide 8'&$%Low-Level Device Drivers• Low-level device drivers normally found in basic I/Osystem (BIOS) ROM and have direct access to hardware.• Good low-level device drivers allow:1. New hardware to be installed.2. New algorithms to be implemented.(a) Synchronization with gadfly, interrupts, or DMA.(b) Error detection and recovery methods.(c) Enhancements like automatic data compression.3. Higher-level features to be built on top of the low level(a) Operating system features like blocking semaphores.(b) Additional features like function keys.4Slide 9'&$%Device Driver Software• Data structures: global (protected)OpenFlag Boolean that is true if keyboard port is open• Initialization routines (public, called by client once)KeyOpen Initialize the keyboard port• Regular I/O calls (public, called by client to perform I/O)KeyIn Input an ASCII character from the keyboard port• Support software (protected)KeyHan An interrupt service handlerSlide 10'&$%Serial Communication Interface (SCI)5Slide 11'&$%SCI Initializationinit ldaa #$33 ;1200 baudstaa BAUDldaa #$00 ;modestaa SCCR1ldaa #$0C ;tie=rie=0,staa SCCR2 ;te=re=1rtsSlide 12'&$%SCI InputInChar ldaa SCSR ;statusbita #$20 ;rdrf?beq InCharldaa SCDR ;SCI datarts6Slide 13'&$%SCI OutputOutChar ldab SCSR ;statusbitb #$80 ;tdre?beq OutCharstaa SCDR ;outputrtsSlide 14'&$%Input Decimal Number; Input a byte from the SCI; Inputs: none; Outputs: Reg B 0 to 255; C=1 if errorDIGIT rmb 1 ;globalInUDec clrb ;N=0InUDloop bsr InChar ;Next inputbsr OutChar ;Echocmpa #13 ;done if crbeq InUDret ;with C=0cmpa #’0blo InUDerr ;error?cmpa #’9bhi InUDerr ;error?7Slide 15'&$%Input Decimal Number (cont)anda #$0F ;0-9 digitstaa DIGITldaa #10multsta ;overflow?bne InUDerraddb DIGIT ;N=10*N+DIGITbra InUDloopInUDerr ldaa #’?bsr OutCharclrbsec ;error flagInUDret rtsSlide 16'&$%SCI Output String; Output a string to the SCI; Inputs: Reg X points to string; String ends with 0; Outputs: noneOutString ldaa 0,Xbeq OSdone ;0 at endbsr OutCharinxbra OutStringOSdone rts8Slide 17'&$%SCI Output Decimal Number; Output unsigned byte to the SCI; Inputs: Reg B= 0 to 255,; print as 3 digit ascii; Outputs: noneOutUDec clra ;Reg D=numberldx #100idiv ;X=num/100,xgdx ;B=100s digittbaadda #’0 ;A=100’s asciibsr OutChxgdx ;D=numldx #10Slide 18'&$%SCI Output Decimal Number (cont)idiv ;X=num/10,xgdx ;B=tens digittbaadda #’0 ;A=tens asciibsr OutChxgdx ;D=numtbaadda #’0 ;A=ones asciibsr OutChrts9Slide 19'&$%Debugging ToolsSlide 20'&$%Debugging Theory• The debugging process is defined as testing, stabilizing,localizing, and correcting errors.• Research in program monitoring and debugging has notkept pace with developments in other areas of software.• In embedded systems, debugging is further complicatedby concurrency and real-time requirements.• Although monitoring and debugging tools exist, manystill use manual methods such as print statements.• Print statements are highly intrusive especially in areal-time system because they can take too much time.10Slide 21'&$%Debugging Instruments• A debugging instrument is code that is added to aprogram for the purpose of debugging.• A print statement is a common example.• When adding print statements, use one of the following:1. Place all print statements in a unique column.2. Define instruments with specific pattern in their name.3. Define all instruments to test a run-time global flag.4. Use conditional compilation (assembly) to turn on/off.Slide 22'&$%Functional (Static) Debugging• Functional debugging is verification of I/O parameters.• Inputs are supplied, systems is run, outputs are checked.• There exist many functional debugging methods:1. Single stepping or tracing.2. Breakpoints without filtering.3. Conditional breakpoints.4. Instrumentation: print statements.5. Instrumentation: dump into array without filtering.6. Instrumentation: dump into array with filtering.7. Monitor using fast displays.11Slide 23'&$%Performance (Dynamic) Debugging• Performance debugging is verification of timing behavior.• System is run and dynamic behaviors of I/O checked.1. Count bus cycles using the assembly listing.2. Instrumentation: measuring with a counter.before rmb 2 ;TCNT value before the callelasped rmb 2 ;# of cycles to execute sqrtmovw TCNT,beforemovb ss,1,-sp ;push


View Full Document

U of U ECE 3720 - Software Development

Course: Ece 3720-
Pages: 6
Download Software Development
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Software Development and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Software Development 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?