0% found this document useful (0 votes)
32 views2 pages

Lab3 Notesx

Uploaded by

Abdul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

Lab3 Notesx

Uploaded by

Abdul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2
ECE332 Lab 3 notes Following the lab 2 notes, start MPLABX and make a new project named LedCount. It is strongly suggested to not have any spaces in file names. For the source code use the file LedCount.asm that is provided in Blackboard. Follow the installation notes to make sure that the PICSimLab plugin is installed into MPLABX. Call, Return, Debug Take a look in the source code for use of the call instruction as well as the return instruction. The call instruction does two things, first it saves the address of the current location in the program into a data structure called the hardware stack. There is space for 32 addresses in the hardware stack. Secondly, the call instruction jumps to the called code. Later on a return instruction returns execution. It is important that each call have a matching return for use later on. ‘The advantage here of using the call and return instructions is that anywhere in the program a delay is needed, a call instruction is used to execute the needed code. Simulator For now in Project Properties, have the connected hardware tool set to, “simulator.” Start the debugger and experiment with the debugger controls. Try to pause, run to cursor. The step over and step into commands behave differently for the call instruction. The step into command steps into the subroutine code being called and step over allows the subroutine called to run to completion, in a sense appearing to step over or not step into the called code. Note that with the debugger active, some of the commands are suspended. To restore those commands, stop the debugger. (debug >> Finish debugger session). PICSimLab Next, in Windows start the PICSimLab Program. + For the simulated board select Board >> Breadboard + For the processor select Microntroller >> PIC18F452 + Set the clock speed Clk(MHz) to 2 + Asmall amount to the right, press the Debug button so that it appears to be debpressed inward + To the upper right is the power switch that you press. The PWR led should appear lit up. + Select Modules >> Spare Parts ‘The Spare Parts window is where you connect outputs and inputs, + Select Output >> LEDs and place the LED panel into the spare parts window + Right click the LED panel and select Properties, the properties window opens Make the following connections in the LEDs properties then click OK. + Pin 1:40 RB7 + Pin2:39RB6 + Pin3: 38 RBS + Pin 4:37 RB4 + Pin 5:36 RB3 + Pin 6:35 RB2 + Pin 7:34 RBI + Pin 8:33 RBO + Active : High Back in the MPLABX IDE window, reopen the Project Properties window and in the Connected ‘Hardware tool click on “Show All” then for the Connected Hardware Tool select, “PicsimLab”. Then click OK. Next start the debugger Debug >> Debug Project Modify Code For PORTB to Count ‘Next, modify the program so that rather than turning an LED on and off, the program increments the count on the PORTB pins. Review the entire program to see where necessary changes are needed so that this time a binary count will appear on the LED panel. As before, experiment with the debugger controls. You should be able to step over, step in, pause, continue, and so forth. Today’s Turn-In Use a word processor to organize a document that you will upload as a PDF document + Atthe top have the title, “ECE332 Lab 3” followed by the date and your name + Ina few sentences describe today’s activity. In particular describe how you changed the program to count rather than just turn the LED on and off. + Pause the debugger and insert into your turn-in a screen shot showing an arbitrary value + Insert the source code using 11 point CourierNew font, single spaced without any inserted paragraph spacing

You might also like