You are on page 1of 22

ECNG2005 labs

Lab exercises for ECNG2005 labs
re: ECNG2006 Introduction to microprocessors
Contributors:
K. Hall
F. Mohammed
C. Radix
A. Sinanan
A. Williams
K. Edwards
A. Joseph
O. Regalado
K. Narine
I. Mohammed
Y. Panchu
S. Patrick
A. Abdool
C. Arneaud
N. Harrichand
H. Lawrence
D. Caberrea
P. Pollucksingh
V. Narine
c 
Dept.
of Electrical and Computer Engineering, U.W.I. , St. Augustine
February 3, 2010

Contributes 30% of ECNG2005 mark:
1.5% Lab 1 – PIC16F877 Toolchain Comparison (1 session)
1.5% Lab 2 – PIC16F877 Basic programming (1 session)
3% Lab 3 – PIC16F877 Further Programming with Basic Peripherals (2 sessions)
9% Lab 4 – PIC16F877 Embedded Application Programming (4 sessions)

ECNG2005 labs (µP)

February 3, 2010

Lab 1-p. 1

Lab 1
ID#
You may not be allowed in the lab if your pre-lab is incomplete. You will have 3 hours in the lab
to complete the exercises. All answers should be written on this lab-sheet in PEN. Please do not
attach any extraneous pieces of paper.
At the end of this unit the student will be able to:

utilize the MPLAB IDE, CCS compiler and other software tools, to develop software for
the MicroChip PIC16xxx series of microcontroller, in C/C++ and assembly language.
Pre-Lab
Please read through the entire lab script FIRST, so you know what is expected of you, and THEN
complete the following questions.
1. Please identify
• your lab group (Thursday 9am-12noon or Friday 1pm-4pm):
• your ECNG2006 uP group designator (e.g. A3):
2. In your own words, differentiate between an integrated development environment (IDE) and
a simulator.
Hint: what do they input/output? what features do they offer? Is one a 5 marks
component of the other? You should use examples to support your answer.

3. Simulators come in three “flavors”:
Groups C1,M1,P1,R1,H1 instruction cycle-level,
Groups C2,M2,P2,R2,H2 machine cycle-level,
Groups C3,M3,P3,R3 gate-level.
In your own words, debate why it is advantageous to simulate at the level assigned to your
5 marks
group, rather than at either of the other two levels.

c 
DECE,
UWI, St. Augustine, Trinidad

St. 2 4. clear OR examine the values of environment variables when you are 1 mark using the Windows GUI?Walk through the procedure c DECE. 2010 Lab 1-p.ECNG2005 labs (µP) February 3. clear OR examine the values of environment variables when you are at the “command line interpreter”? Replicate the command for any ONE of these actions on the environment variable ”PATH” below. Augustine. For the Microsoft Windows XP operating system: (a) How do you open a “command window”? 1 mark (b) What is the meaning of the term “command line interpreter”? What is the command 1 mark line interpreter for windows? (c) What is the meaning of the term “command line parameter”? 1 mark (d) How do you specify command parameters when you are using the “command line inter1 mark preter”? (e) How do you specify command parameters when you are using the Windows GUI? 1 mark (f) What is the meaning of the term “environment variable”? 1 mark (g) How do you set. UWI. 1 mark (h) How do you set. Trinidad .

M1 P1 R1 H1 C2 M2 Tool MPLAB SDCC GPLINK MPASM MPSIM Command Batch files Category IDE Compiler Linker Assembler Simulator Script Tool PICC CCSC MPLINK GPASM GPSIM MinGW makefiles Group(s) P2. Students are advised to check manufacturing company’s website for USER blogs comparing the product with its competitor 7 marks Group(s) C1.ECNG2005 labs (µP) February 3. Trinidad . St.R2 H2 C3 M3 P3 R3 c DECE. For your assigned tool. 2010 Lab 1-p. identify and explain TWO features (apart from price) which make it superior to the competing tool in it’s category. Cite all references. 3 5. In this lab we will be looking at different tool-chains which can be used with the PIC16F877 under Windows XP. You should support your arguments using user testimonials which are not supplied by the tool creators. Augustine. UWI.

Algorithms are descriptions of how a function can be achieved.R2.H2 Exploits floating point representation (e.dattalo. Trinidad .org/fpoint/) Groups C3. Use the calculation of log5 25 to support your answer. St.P2.M2.H1 Borcharts algorithm (e.com/technical/software/pic/piclog.com/technical/theory/logs. Groups C1.R1.g http://wehner.html) Groups C2. and contrast it with the one 5 marks used in this lab (looplogm. Augustine. we will be using a particular algorithm to calculate the logarithm of an integer. It is based on the principle of comparing the number to an incrementally increasing exponent of the base.dattalo.M3. 4 6.g.g. UWI. 2010 Lab 1-p. http://www. in this lab.P3.M1.R3 Uses a lookup-table (e.html) Read about the alternative algorithm you have been assigned.ECNG2005 labs (µP) February 3. http://www.c).P1. c DECE. This is not the only possible algorithm.

please install software in the specified order. or fails to set data in registry. Please Install in the same directory as the GPUTILS i. for example \ Program Files\ Microchip\ Third Party\ PICC. Trinidad . if so please use the files in the installation directory of the CD.e. We will not be able to give support for problems experienced under other operating systems. UWI. Third Party\ PICC GPUTILS Please install in Third Party\GPUtils GPUTILS MPLAB plug-in Only required for MPLAB versions greater than 6. A CD can be obtained from Mr. Third Party\ GPUtils GPSIM Please install in Third Party\ GPSIM SDCC Please install in Third Party\ SDCC MinGW Make Please install in Third Party\ MinGW PIC16F877 Visual Simulator Please install in Third Party\ Visual Simulator. the default installation directory is either \ Program Files\ Microchip OR \ Program Files\ MPLAB OR \ Program Files\ MPLAB IDE.INI for versions of MPLAB greater than 6. To avoid problems. If the installation either fails to find MPLAB. or the software can by downloaded from their respective sites. c DECE. Installation may complain that it cannot find the REG files. Augustine. 2010 Lab 1-p.ECNG2005 labs (µP) February 3.e. St. Administrative privileges are required for a proper installation. Hall. CCS PCWH Please install in a subdirectory of your MPLAB installation. All other software should be installed here.0.0. then you should install the plug-in. Microchip MPLAB IDE Depending on the version. CCS MPLAB plug-in Only required for MPLAB versions greater than 6. Please create a directory called Third Party within the installation directory.0. 5 Software Installation Students may wish to install the same software on their own machine. Please note that the OS in the lab is Windows XP. Please Install in the same directory as the CCS PCWH i.

2010 Lab 1-p. Finally. double-click on the icon for the drive. create a directory on the Z: drive . Next. • Click OK or APPLY. UWI. Trinidad . • Right click and select New Folder. • Ensure that the checkbox labelled Hide extensions for know files is clear.zip into the directory you have just created. please ensure that the computer is set up to show file extensions: • Click on My Computer then select the following from the menu(s) and pop-up windows: Tools -. This is the directory you will work with during the lab. Augustine. Please ENSURE that you delete your directory at the END of the lab (you can copy it to your Z: drive or a key first!) c DECE.View. • In the My Computer window. • Name the directory uPxxxxxxxx where xxxxxxxx is your ID number.Folder Options -. St. 6 In the Lab Before you start. unzip the archive ecng2005-uP-lab1.ECNG2005 labs (µP) February 3.

Show your lecturer or TA and have them sign/stamp your script here. Tick each of the following items as you try it: • The prompt tells you which directory is currently active. cd \anotherfolder. D:\myfolder • To change directories we type the command cd followed by the name of the directory to which we wish to move e. Now lets get to work! (a) Use the cd command to make the folder you created your active directory. Open a command window.g. We also have directory shortcuts . Try dir /?. but usually at least one will. St. which stand for the current and parent directories respectively. Use the space below to make notes to help you remember how to do this. • To change drives we type the new drive letter followed by a colon. 1 mark (b) Within a directory we can list the files and subdirectories using the dir command. e. Show your lecturer or TA and have them sign/stamp your script here. Most commands have help.ECNG2005 labs (µP) February 3.g Z: • If we do not specifiy the full path of the directory then we will move to a subdirectory of the current directory. and . To display help for a command.g. Augustine. Show your lecturer or TA and have them sign/stamp your script here. Use the space below to make notes to help you remember how to do this. or /?. UWI. 1 mark (c) At the command line we often cannot remember all the options for a command. The dir command also works if we give it the path to a directory e. Which options are available for the dir command? Choose one and use it. 2010 Lab 1-p. The directory name is the command line parameter that we supply for the command cd. Write a short description of what you did and what happened.g. e. try typing the command name followed by -h . Trinidad 1 mark . Not all of these options will work with all programs. c DECE.. 7 Command Line Basics 1. /h. dir C:\otherfolder Use the dir command to list the files in another directory .

Show your lecturer or TA and have them sign/stamp your script here. regardless of the directory from which it is called. Write down the final batch file commands here. Use the dir command to look in the directory for files with the . When you set or clear environment variables at the command line.asc) in the command window. Print the contents of any text file (we’ve supplied lab1read. Trinidad 1 mark . Augustine. Show your lecturer or TA and have them sign/stamp your script here. it can be tedious to type and retype them. Edit the batch file (you can use Windows Notepad) and change it so that it uses the commands you have learned to change active directory to your folder. When you type the name of the batch file. 2 marks (f) Type set at the command line to see ALL the environment variables which are currently set.”Environment Variables”. If you have a sequence of commands that you execute regularly. What happened? 1 mark Show your lecturer or TA and have them sign/stamp your script here. c DECE. the changes will not be there. 1 mark (e) We can even start applications. right-click on ”My Computer”. Create an environment variable called ECNG2005 and then change the value from Test to Ok.ECNG2005 labs (µP) February 3. UWI.”Advanced”. If you ever need/want to make global changes to environment variables. 8 (d) We can print the contents of a file to the screen using the command type. If you open another window. and type out the contents of lab1read. St. You should close the instance of Windows Notepad which just opened before proceeding. Open a new window and have a look.bat extension) at the command prompt. the changes only affect that command window. To start Windows Notepad type notepad.bat extension.asc. Type the name of the file (excluding the . Save and test your batch file. You can also use the set command to create and alter environment variables. the commands will be executed in sequence. Close your current command window. 2010 Lab 1-p. You can place a sequence of commands in an ASCII text file called a script or BATCH file. What command(s) did you use? Show your lecturer or TA and have them sign/stamp your script here.

Some environment variables actually control how the command window/computer behaves. it will look like “junk”. You will be able to open the resulting *. Please close all command windows before proceeding. You can edit any source code file in any ASCII text editor. When you click build.cpp files in Windows Notepad. Go ahead any create a Visual C/C++ project.c or *. For example the PROMPT environment variable controls how the command prompt is displayed. Trinidad 1 mark . If you type the name of a program which is not in the current directory. Windows Notepad is an Editor. Does notepad still start from the command prompt? Show your lecturer or TA and have them sign/stamp your script here. 9 (g) Environment variables are useful. and not in one of the search paths. they often specify default values to applications. it passes a command (just like the ones we have just used) to start the compiler. then the computer will complain. UWI. We are going to investigate compilers for the PIC16F877. Change the prompt so that it displays your name before the drive letter and path. Visual C/C++ is an Integrated Development Environment that includes an editor.ECNG2005 labs (µP) February 3. You may use the prompt or set commands to alter it. and then use the changed file in Visual C/C++. Augustine.simply close the file. Build Tools Compilers take ASCII text files. This is IMPORTANT! There is no need to cut and paste code between different editor applications . 2010 Lab 1-p. as their input.exe at the prompt). What command did you use? Show your lecturer or TA and have them sign/stamp your script here. c DECE. If you open a file that is not ASCII text in any text editor. 1 mark (h) The PATH environment variable lists all the places (search paths) that the computer will look for a program. St. that contain source code. Try clearing the path variable (set PATH=). Start Windows notepad by typing notepad (or notepad. then open the same file in another editor. change them.

What was dis1 mark played? If you have any errors. Open an ASCII text editor (e.exe looplogm. Place a COPY of looplogm. • Run the compiler command: ccsc. Augustine. ask your lecturer/TA for assistance. A typical command would look like: set PATH=%PATH%. St.c. Be sure to include a #DEVICE line in your file to specify the target processor (PIC16F877).c in each of your directories.c in this directory.sym looplogm. In this window we will utilise the CCS PIC-C compiler to compile the code. write out one/two lines from the file.c looplogm. • You need to set the PATH environmental variable so that ccsc. List the names and extensions of the files which have been created. Windows Notepad) and examine the code in looplogm. The command will depend on the path to the PICC directory on your computer. 2010 Lab 1-p. and the initial value of x should be 81. A typical command would look like cd D:\uP12345678\PICC Edit the copy of looplogm. 10 2. UWI.hex Show your lecturer or TA and have them sign/stamp your script here. c DECE. (Try to choose interesting ones!) Filename Filesize ASCII?(human Extract (if ASCII) readable? looplogm.exe to run correctly. and if it is. (a) Open a new command window.F:\Program Files\MicroChip\Third Party\PICC • You need to change the active directory to PICC subdirectory of your personal folder. Make two subdirectories called SDCC and PICC in your working directory. Trinidad 2 marks . look at your folder. • Once your file has compiled correctly. The initial value of n should be 3.ECNG2005 labs (µP) February 3.g. For each file: Indicate whether it is an ASCII text file.c +FM +P -J. This code will calculate the base-n logarithm of the integer x. If not correct and save the file.

c in the SDCC directory. Test your final batch file and write it below. In your batch file called myccsc. (b) Open a new command window. How are you going to do this? • Make sure there is a copy of looplogm. Test your batch file in a new command window.ECNG2005 labs (µP) February 3.c. Please 1 mark note that the command line options are case sensitive. • You need to set the PATH environmental variable for sdcc. change the directory. Trinidad . Show your lecturer or TA and have them sign/stamp your script here. In this window we will utilise the SDCC compiler to compile the code. c DECE. UWI.c. If you replace the name of your file within the batch file with %1 then you can specify the file to be compiled along with the name of the batch file at the command line. we will specify the processor on the command line for SDCC.c. Augustine. • Run the compiler command: sdcc -S -V -mpic14 -p16F877 myfile. ask your lecturer/TA for assistance. Unlike the #DEVICE needed for PICC. and run ccsc on looplogm. What was displayed? If you have any errors. St.exe to run correctly. 1 mark How are you going to do this? • You need to change the active directory to the SDCC subdirectory of your personal 1 mark folder. 2010 Lab 1-p. For example myccsc myfile to compile myfile. 11 • We could also create a batch file to run CCSC compiler. No preprocessor directives are needed for this compiler.bat place the commands you have just learned to set the path. 1 mark Close all command windows.

The final file which is required for “download” to the PIC16F877 microcontroller is an Intel HEX format file *.asm looplogm. c DECE. UWI.c looplogm. 12 • Once your file has compiled correctly. Trinidad 1 mark .hex file. look at your folder.hex". write out one/two lines from the file. List the names and extensions of the files which have been created.asm. Assemblers and linkers can also be used for code which you write directly in assembly. (Try to choose interesting ones!) Filename Filesize ASCII?(human Extract (of ASCII files) readable?) looplogm. 2010 Lab 1-p. St. You should have noticed that although both compilers generated files. CCSC accomplished the compiling. Close all command windows. SDCC generated an assembly language file *. and if it is.bat to run the SDCC compiler. Try it below! Show your lecturer or TA and have them sign/stamp your script here. Augustine.d Show your lecturer or TA and have them sign/stamp your script here. For each file: Indicate whether it is an ASCII text file. assembling.ECNG2005 labs (µP) February 3. To complete the job for SDCC we would need to use a separate assembler and a linker. only CCSC created a ". and linking in one step. 2 marks • We could also create a batch file named mysdcc.

13 3. 2010 Lab 1-p. (a) Once your file has compiled. For each file: Indicate whether it is an ASCII text file. Add the path of GPUTIlS to your path. Trinidad 4 marks .hex looplogm. Augustine. look at your folder. Alter your SDCC batch file so that the search path for gpasm. • set GPUTILS_HEADER_PATH=F:\Program Files\MicroChip\Third Party\GPUtils\header • set GPUTILS_LKR_PATH=F:\Program Files\MicroChip\Third Party\GPUtils\lkr • gpasm -c looplogm.lib” Run the SDCC batch file in a new command window.exe and gplink.o Filesize ASCII? Extract Show your lecturer or TA and have them sign/stamp your script here.o (line wraps) “F:\Program Files\MicroChip\Third Party\SDCC\lib\pic\libsdcc. Add the following lines at the end of your batch file: ( These commands are available in the file batfileadd. (Try to choose interesting ones!) Filename looplogm. They are located in Third Party\GPUtils\. write out one/two lines from the file. Compare the files generated by the two processes from the same original C file.ECNG2005 labs (µP) February 3. List the names and extensions of the ADDITIONAL files which have been created by gpasm and gplink. St. UWI.exe is added. c DECE.txt. Are they identical? Did you expect them to be? Explain why you did or did not think so. and if it is. Show your lecturer or TA and have them sign/stamp your script here.asm • gplink -m -o looplogm. ask your lecturer/TA for assistance.hex looplogm. 2 marks 4. assembled and linked correctly. you may need to change looplogm to %1 if you have used that option previously). If you have any errors.

c F:\Program Files\MicroChip\Third Party\SDCC -S -V -mpic14 -p16F877 $< %. Trinidad . and how they come together to form the final executable. 14 Build Tools Roundup . Augustine. the rule will match any file which has the same suffix. but where we want to establish rules for compiling files it is often more productive to use a makefile.asm: %. (a) The batch file works well for a single file.o F:\Program Files\MicroChip\Third Party\gplink -m -o $@ $< \\ F:\Program Files\MicroChip\Third Party\SDCC\lib\pic\libsdcc. Then the following lines (each starting with a TAB) list the command(s) used to make the target ($@) from the dependencies($<).o: %. • Open a command window and add the paths for sdcc. • Check the rules in the file called ”makefile” (no extension) in the SDCC directory. c DECE. ask your lecturer/TA for assistance. If you have any errors. • Type the following command: mingw32-make myfile. Show your lecturer or TA and have them sign/stamp your script here. We will only use a simple makefile here (an electronic copy of makefile is available). and mingw\bin to the search path. Write your rule(s) down here.ECNG2005 labs (µP) February 3. %. Using this makefile we can specify different targets. UWI.Make Utility 5.hex 4 marks Delete myfile.hex and try it again. • Test your makefile is syntactically correct by using the command:mingw32-make.hex: %. • Make the SDCC directory the active directory.e. This is one advantage over using scripts or batch files. You should notice that make automatically builds only the files that need to be updated. gputils. This is followed by a list of dependencies (files that must exist in order to produce the target) .asm F:\Program Files\MicroChip\Third Party\gpasm -c $< %. 2010 Lab 1-p. St. (b) Challenge(Bonus 10 marks): Place a makefile in the CCSC sub-directory that could be used to build a hex file using the ccsc compiler.lib Each rule starts in the first column (no space or TAB) and specifies the Target. Our targets all start with % which is a wildcard i. Show your lecturer or TA and have them sign/stamp your script here.

The command window reports the status of the processor with each step. Close GPSIM when you are done. Show your lecturer or TA and have them sign/stamp your script here. Augustine. using the menu on the button bar. What range of instruction memory locations are occupied by looplogm. The first of the development tools we will look at is the simulator. This has two tabs. Trinidad 1 mark 1 mark 1 mark 1 mark . Even though we have compiled the code on a HOST PC. 2010 Lab 1-p. The HOST PC cannot normally run this file by itself.hex. UWI. c DECE. Show your lecturer or TA and have them sign/stamp your script here.hex You will see text printed in the command window and a button bar will pop up. and equivalent instruction code.hex? Show your lecturer or TA and have them sign/stamp your script here. (d) Open the StopWatch Window. while the other shows the bytes of instruction code stored in the program memory in a matrix form. The processor should stop before executing the line you have indicated. To start gpsim. one tab shows the assembly language code. (c) It is inconvenient to keep stepping through a program. (a) Open the Program Memory window. St. To move more quickly. Use the following command to start gpsim: gpsim -p pic16f877 looplogm. How many cycles are being used by looplogm. Change the active directory to SDCC (or CCSC for next question!). This is a convenient alternative for the developer. Reset the processor (using the button on the button bar). with each instruction next to it’s stored address. 6. You can step through the assembly language code using the step button. By looking at the RAM window while you step. • • • • Open a new command window. A simulator is a program which will allow the HOST PC to interpret the machine code intended for the TARGET processor. and gputils. GPSIM is a Windows based simulator for the PIC16F877. Now we will look at tools which assist in the development of correctly functioning programs.ECNG2005 labs (µP) February 3. as software development can start even though the hardware is not available. This is used to determine how many cycles the code takes to run. Play with the Stopwatch and the breakpoint to see how long the code takes to execute. 15 Development Tools We have looked at tools used to build the hex file from the source code. How many data memory locations are being used by looplogm. Add the search paths for gpsim. This is a matrix view of the data memory. the output file needs to be loaded onto a TARGET microprocessor in order to run. you can see how information moves from one register to another in response to the instructions. (b) Open the RAM window. set a BreakPoint by double clicking on a program line in the Program Window. using the menu on the button bar.hex? Show your lecturer or TA and have them sign/stamp your script here. then run.

Augustine. • Click the DECODE button. you will see the actual contents of the HEX file. c DECE. Trinidad . • Red Dot represents information flow due to the execute phase of the pipeline. 8. The currently executing phase is displayed on the left. the main window will look like the layout diagram shown in your data-sheet book. to interpret the instruction op-codes & operands as mnemonics. (b) Click the Back to the interface button and run the simulator by Clicking the start processing button. 2010 Lab 1-p. data memory locations. How is pipeline execution affected? 2 marks You should close/pause the PIC16F877 Visual Simulation when you are finished. Q1 to Q4. UWI.e. You will see two dots moving around the screen. St. Each phase is made up of 4 sections. you should Choose Select File to Decode. Locate either of your compiled hex files and press OK. It does not show us what goes on within the instruction-cycle. this simulator loads in the Hex file output by the compiler. a window named “Decode Hex File” will come up. the duration of which is set by the clock. Just like the GPSIM simulator. (a) Does this match the GPSIM views of program memory? Is that what you expected? 1 mark Explain your answer. 16 7. it is a cycle-level simulator.hex generated using 3 marks CCSC (instead of the one generated using SDCC). DECODE HEX File. GPSIM is an instruction-level simulator.ECNG2005 labs (µP) February 3. • Launch the PIC16F877 Visual Simulation from the Windows Menu. In the “Hex Data” Field. and cycles required by the version of looplogm. • Blue Dot represents information flow due to the fetch phase of the pipeline. Show your lecturer or TA and have them sign/stamp your script here. Repeat the process described in 6 to measure the number of instruction memory locations. When you launch the PIC16F877 Visual Simulation. The PIC16F877 Visual Simulation was written to illustrate what goes on inside the microcontroller on each clock cycle i. Click on TASKS. Pay particular attention to what happens when a goto instruction is executed. • To load in a hex file. • When parsed (using the Intel Hex format) the byte-codes to be loaded at particular addresses are displayed in the “Parsed data” Field.

mcw”. It can be used to view and edit any ASCII-type file. Like most Windows based IDE’s there is a menu. we can automatically call appropriate programs. Show your lecturer or TA and have them sign/stamp your script here. Then browse and find the PICC folder you created for the PROJECT DIRECTORY box and click NEXT. and customize environmental variables. • Then go to WINDOW on the menu bar and select “project1. St. scripts. Try opening different files in the CCSC directory.exe. Augustine. Create a new project in your CCSC subfolder. • Enter “myproject” in the box named PROJECT NAME. You will see “looplogm. Environmental variables.c from the CCSC directory and then click FINISH in the new window. The MPLAB IDE is an example of an IDE that comes with it’s own tools. • Click PROJECT on the menu bar and select PROJECT WIZARD.c” link and your program will appear. toolbar. while others contain no tools and must be configured to work with your tools. Now double click the “looplogm. From the DEVICE drop down menu select PIC16F877 and click NEXT.c to . UWI. 9. Instead of manually calling separate programs to translate from . In the PROJECT WIZARD box click NEXT.asm to .c” . Trinidad 1 mark . 17 Build & Development Tools Roundup The Integrated Development Environments(IDE) An IDE allows us to perform all the tasks we have looked at from a single interface. and command line parameters. • A window will now come up with the buttons ADD and REMOVE. Select CCS C COMPLIER form the ACTIVE TOOLSUITE dropdown box and then click NEXT. c DECE. add your file looplogm. Show your lecturer or TA and have them sign/stamp your script here. but allows you the option to choose other build tools (like the CCS compiler). workspace and a status bar. makefiles. (a) Start the MPLAB IDE from the menu. batch files. and command line parameters can all be used with an IDE to make it operate seamlessly with a tool-chain.ECNG2005 labs (µP) February 3. 2010 Lab 1-p. 1 mark (b) The MPLAB IDE has a built in editor.o to . Some IDE’s are supplied with their own tool-chain.

Show your lecturer or TA and have them sign/stamp your script here. Are these views similar to the ones we had in the other two simulators? 2 marks (d) The PC value displayed in the status bar is set to 0x00. What do we see happening? Is this similar to what happened in the other two simulators? Show your lecturer or TA and have them sign/stamp your script here. Trinidad 3 marks . a view of RAM and a stopwatch. You should be able to use the files which have already been generated. To display the Program Memory click on the VIEW > PROGRAM MEMORY menu item. 1 mark (f) In the GPSIM simulator we used breakpoints. UWI. to compile the project. A build window should appear stating the build was successful. Click on the PROJECT > BUILD ALL menu item (or press F10). Have a close look. The buttons at the bottom left of the window.ECNG2005 labs (µP) February 3. Can you see the command used to launch the compiler? Write it below. Locate the equivalent functions in MPLAB. Augustine. Go to the menu bar and select DEBUGGER > SELECT TOOL > MPLAB SIM. St. 18 (c) The MPLAB IDE also has a built in simulator. State the name of each the view. To advance to the next instruction location click on the DEBUGGER menu and choose STEP OVER from the menu. This means that you will be executing your code on the simulator. c DECE. Let us investigate how to advance the PC to the next instruction location. Show your lecturer or TA and have them sign/stamp your script here. allow you to access three different views of the Simulator Program Memory. and identify how the views differ from each other. 2010 Lab 1-p. 2 marks (e) The MPLAB IDE project has been set up to use the same CCSC compiler we used at the command line.

Trinidad . and the number of cycles that the program requires to run. Augustine.c. UWI. you could also consider the accuracy/suitability of the final solution.ECNG2005 labs (µP) February 3. 2010 Lab 1-p. using the skills we have acquired during this lab. St. The comparison criteria to be used are: I the size of the source code file in bytes II the number of instruction memory locations used by the final program III the number of data memory locations used by the final program IV the number of instruction cycles required to execute the program on test case A V the number of instruction cycles required to execute the program on test case B The test cases to be used are A: log3 81 and B: log5 25. c DECE.hex file depends on: • the algorithm implemented • the compiler/assembler used to generate the *. the number of instruction and data memory locations used. In addition to the specified comparison criteria. 19 Performance Comparison So far we have compared the sizes of files. Challenge Question: (Bonus 10 marks) Use the test cases to discuss WHY the algorithm you researched for the pre-lab is likely to perform better or worse than the algorithm implemented in looplogm. The performance of the final *. 10.hex file • the language and data types used for implementation We will investigate each of these in turn.

Trinidad . Use data from previous pages. Total marks 100. who will sign/stamp your script as confirmation.c with CCSC looplogm. without due acknowledgement in the text. Demonstrate this to your TA/lecturer. I have read and understood University Examination Regulations 73. Justify 3 marks your choice. DECLARATION I declare that this assignment is my own work and does not involve plagiarism or collusion.ECNG2005 labs (µP) February 3. Demonstrate the changes made to your TA/lecturer. COLLUSION Collusion is the presentation by a student of an assignment as his or her own which is in fact the result in whole or part of unauthorised collaboration with another person or persons. The program liblogm. or from any other source (e. unauthorised collaboration is any form of collaboration which does NOT fall into one of the following categories: • verbal or written discussion/clarification of question and/or related concepts • assistance in troubleshooting circuitry and/or using/operating the IDE/debugger Department of Electrical and Computer Engineering PLAGIARISM Plagiarism is the presentation by a student of an assignment which has in fact been copied in whole or in part from another student’s work. 12.c with CCSC liblogm. and modify the programs and re-run them to obtain data to 2 marks update the first two rows in Table 3. who will sign/stamp your script as confirmation. 10 marks Compile and/or assemble programs as necessary to fill the second two rows of the Table 3.c uses the compiler provided math libraries to calculate the answer.g. Use your data to identify which is the most effective implementation of logarithm. Demonstrate this to your TA/lecturer. and explain whether this is what you had expected. Signed: Date: (Department of Electrical and Computer Engineering) c DECE. 13.asm Table 1: Performance comparison results 11. You may use either the MPASM 5 marks or the GPASM assembler. who will sign/stamp your script as confirmation. St. 2010 Lab 1-p. 20 Item I II III IV V Units bytes instruction-words data-words cycles cycles looplogm.75. published books or periodicals). 14.76 and 79 regarding cheating.c with SDCC liblogm. This exercise is worth 5% of your ECNG2005 lab mark. Make a new project in MPLAB to assemble asmlogm. PLAIGIARISM DECLARATION: For the purposes of this exercise. Augustine. Make the measurements needed to update Table 3.c with SDCC asmlogm. UWI.asm.

1. Trinidad .ECNG2005 labs (µP) February 3. 2010 Lab 1-p. 21 Write the number you have been assigned here . Who is the manufacturer of the tool-chain? . UWI. • Identify one way in which this lab exercise could be improved. What is the price of this tool-chain? 5. Where did you find the information? . Augustine. – utilize the MPLAB IDE. c DECE. and other software tools. to develop software for the MicroChip PIC16Cxxx series of microcontroller. . 3. 2. Answer the following questions for the TARGET platform whose number you were assigned. CCS compiler. . Which HOST platform/operating system(s) can use this toolchain? 6. 4. in C/C++ and assembly language. Which of the following items does the tool-chain contain? • IDE • pre-defined header files • make utility OR makefiles • pre-defined library files OR librarian • batch/shell files OR other scripts • simulator • assembler • downloader • disassembler • debug kernel + monitor • linker • other • compiler Reflection & Feedback • Indicate the objectives that you feel you have achieved in this lab exercise. St. • Which aspect of this lab exercise did you have the most difficulty understanding? • Which aspect of this lab exercise did you like best? Why did you like it? • Identify one thing (if any) that you learned while doing this lab exercise. What is the name of the target platform? .