55:036

Embedded Systems and Systems Software

Spring, 2007

 

SECOND LABORATORY EXPERIMENT

 

Due Dates:     Prelab: Tuesday, Feb.6, in class.

                        Lab Report: Thursday, Feb. 15

 

Objective: 

 

The purpose of this lab is to become familiar with the facilities and development tools in the Embedded Systems Laboratory and to gain some experience in working with a simple PIC assembly language program.

 

Lab Description:

 

Part A:

 

Download the source file (P1.ASM) from the web-site www.picbook.com.  This is the program described in Chapter 5 of the text.

 

Assemble and link this program using the MPLAB Development Environment, as described in class on Thursday, Feb. 1.

 

Download the program to the processor on your QwikFlash board as described in Section 5.10 of your text.  Note that the Tera Term Pro terminal emulator is already installed on the computers in the lab.

 

Run the program and verify its correct behavior as described in Section 5.10.  Use the logic analyzer or scope to observe the C2 output from the QwikFlash Board and measure the period of the observed waveform as accurately as possible.

 

Part B:

 

Modify the P1.ASM program to add an additional subroutine to blink the LEDs D4, D5 D6 in sequence at an 8 second rate, i.e. LED D4 should be illuminated for 8 seconds (with D5, D6 turned off), then D5 should be illuminated for 8 seconds (with D4, D6 off), then D6 for 8 seconds, then back to D4, etc.  Do not modify the original LoopTime subroutine or disrupt the blink-alive functionality of the original program--i.e. the BlinkAlive LED (D2) should continue to blink once every 2.5 seconds.  Assuming that your new subroutine is called ScanLEDs, the Mainline portion of your modified program should look like:

 

           


Mainline

              rcall     Initial      

             

     Loop      btg       PORTC, RC2

              rcall     BlinkAlive

              rcall     ScanLEDs

              rcall     LoopTime

              bra       Loop

                                   

Assemble, download and debug your modified program until it works correctly.

 

Part C:

 

 Devise a way to measure the combined execution time by the ScanLEDs and BlinkAlive subroutines during each iteraton of Loop  (Hint: introduce one or more additional bit toggles of RC2 so that you can measure this execution time using a scope connected to the C2 output.)  Measure the combined execution time of these subroutines as accurately as possible and record the measured value.

 

Prelab:

 

Read Chapter 5 of the text and familiarize yourself with the program P1.ASM

Design and implement the modifications to P1.ASM to implement the additional functionality described in Part B, above.

 

To be submitted on Tuesday, Feb. 6:  Pre-lab report in the format specified in the Laboratory Guidelines document. The pre-lab report should include a copy of the source code for the new subroutine to be added to P1.ASM to implement the additional functionality in Part B and a description of any other needed modifications to P1.ASM to implement the new functionality.

 

Lab Report:

 

Your lab report should follow the general format described in Laboratory Guidelines document. In addition, answer the folllowing two questions:
1. With respect to Part C, compare the combined execution time of the ScanLEDs + BlinkAlive subroutines as measured in the lab with the value predicted by hand-counting instruction execution cycles.  How cloesely do they agree?  Explain any discrepencies.
2.  Does the execution time overhead of the ScanLEDs and BlinkAlive subroutines affect the accuracy of the 10msec. timing Loop--e.g. does the overhead introduced by these subroutines cause the ALIVECNT counter in BlinkAlive to be decremented at a rate slower than 100 HZ?  Carefully justify your answer.