Unformatted text preview:

Exercise delayprogramflowchartcodingexecutionWhat you have learnedEMCH 367 Fundamentals of Microcontrollers Exercise DELAYEXERCISE DELAYOBJECTIVEThis exercise has the following objectives:- Review the use of branching- Illustrate a delay (wait) program- Demonstrate a flowchart and its relation with the program tasks list and program code- Demonstrate the calculation of clock cycles from the clock cycles of each operation- Demonstrate the calculation of MCU time from the clock cyclesPROGRAMThe program does the following:(i) Define variable DELAY at $0000(ii) Load DELAY into accB(iii) Decrease accB by 1(iv) Branch back to (iii) if theresult is higher than zero(unsigned >0)(vi) SWIFlowchart 5 point(s) Code 4 point(s)FLOWCHARTDraw a flowchart for the program in the space provided above.CODINGType the essential code for this program in the space provided above. Code the program in to thepersonalized file LASTNAME_Firstname_delay.asm using the standard template.EXECUTIONOpen THRSim11. Close the Commands window. Open the memory window. Open and assembleLASTNAME_Firstname_delay.asm. Tile windows, set breakpoint, and reset registers. Set standardlabels (Label/Set Standard Labels). Set display of memory DELAY to decimal. Optimize the look of yourscreen. a) Put 3 into variable DELAY by modifying it’s corresponding value in the memory list.Insert your screen: 1 point(s)Dr. Victor Giurgiutiu Page 1 1/14/2019EMCH 367 Fundamentals of Microcontrollers Exercise DELAYNote the value of “Clock Cycles”. .b) Step to the subroutine and after each step observe the number of cycles taken byeach operation. Enter these values in Table 11. Look up the opcodes in the MotorolaMC68HC11 Programming Reference Guide pocketbook and verify the numbers inthe ‘Cycles’ column of the Instructions table with the numbers that you entered inTable 1. Put a check mark here ___ when you did so. Did it agree? __Y; ____N1 point(s)c) After each pass through LABEL1, accB is decremented by one. When reaching thebranch instruction BHI, the program branches back to LABEL1 if the result of thedecrementation is still higher than zero. After the first pass, accB was decrementedfrom 3 to 2. The screen looks like this: (Insert your screen) 1 point(s)Note that clock cycles counter shows 12. This number is made up as follows: 2+2+3+2+3=12. Duringthis pass, accB was decremented from $03 to $02. These are illustrated in the table below:Table 11 Cycles count table, actual and cumulative, opcode by opcode, after pass 1.Pass 1 Pass 2 Pass 3 Pass 4AccB start $03ActualcumulativeActualcumulativeActualcumulativeActualcumulativeActualcumulative2 2START NOP 2 4???? ???? 3?????? ????BHI ????SWIAccB end $02Note: ??? represents the codes you write in the program.After the second pass, paste your screen below: 5 point(s)Note that value of the clock cycles counter. Explain how is this number made up. 4 point(s)Fill in the entries for Pass 1 and 2 in the in Table 11. 20 point(s)Dr. Victor Giurgiutiu Page 2 1/14/2019EMCH 367 Fundamentals of Microcontrollers Exercise DELAYFill in the entries for Pass 3 and 4 in the in Table 11, until the program exits the loop and reaches SWI.24 point(s):Paste your screen at the end of the pass. 5 point(s)Explain what happens 4 point(s)Derive a formula for calculating the number of cycles. Write the formula below 8 point(s)N_cycles=??+=___+DELAY*?? *___ =??=_________________________?a) Reset the simulator. Run the program by pressing the Run button. Set a breakpointat SWI. The program stops when accB has been reduced to zero. Record the values shown onthe task bar:Simulated time = ________ sec = _______ micro-sec 2 point(s)Clock Cycles = ________ 2 point(s)b) Reset the simulator. Put value 20(decimal) in DELAY. c) Predict the number of cycles with your formula (N_cycles=___??+DELAY*___)??=?+???*??=???2 point(s).Calculate the time D_t=N_cycles*0.5=??*0.5=??? = ______ micro-sec=_________???????? sec. 2 point(s)d) Run the program. Insert screen capture when it stops: 1 point(s)e) Record the values shown on the task bar:Simulated time = ________ sec = _______ micro-sec 3 point(s)Clock Cycles = ________ 3 point(s)Do these values agree with your predictions? __Y ____N 3 point(s)Dr. Victor Giurgiutiu Page 3 1/14/2019EMCH 367 Fundamentals of Microcontrollers Exercise DELAYWHAT YOU HAVE LEARNEDIn this example, you have learned:- The use of variables- The use of labels and branching- The flowchart and its relation with the program tasks list and program code- Calculation of clock cycles from the clock cycles of each operation- Calculation of MCU time from the clock cycles knowing that each clock cycle lasts 0.5 micro-sec- How to read clock cycles and simulated time in the simulator window- How to write a delay (wait) program- New words and notations: variables, labels, branch, clock cycles, MCU time.Dr. Victor Giurgiutiu Page 4 1/14/2019EMCH 367 Fundamentals of Microcontrollers Exercise DELAYDr. Victor Giurgiutiu Page 1


View Full Document

SC EMCH 367 - Exercise Delay

Download Exercise Delay
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 Exercise Delay 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 Exercise Delay 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?