2 Records Procedure 4 Debugging the program (Simulator) Procedure # Function Comments PC = 0x4 4.2 Set PC at Cursor W = 0xff; current value in WREG is FF Program memory window: The program counter is set to the 00004 address in memory PC changes from previous address (0x4) to the current address (0xC) Program memory window: 4.3 Run to Cursor The program counter is set to the 0000C address in memory Run program to the line which is selected. All instructions between the start and end points will be executed Open watches window (WindowDebuggingWatches) With the watches window you can monitor selected file registers, and variables. This window will show the Name, Type, Address and Value of the selected variable. You can also change the value of certain variables (for example, WREG) 4.4 New Watch 4.5 Set Breakpoint After clicking the play button, the program will only run up to the break point and stop. The new PC location will be at the address of the instruction where the breakpoint is located 4.6 Reset The PC moves back to the start of the program which is location 0 in memory. 4.7 Finish Debugger Session This terminates the debugging session; the user can no longer run the program and check the states of the various variables and file registers as they change. 4.8 Run with Pre-set Breakpoint The breakpoint is still set. The PC stopped at the address location of this instruction (0x14) and all the previous instructions were executed. Step Into The PC moves to the next instruction (call delay_blink). After stepping into again, the PC moves into the subroutine called by the previous instruction (0x76 in memory). This was done despite the breakpoint still being in place. Step Over The main difference between step into and step over is that when the PC arrives at a call for a subroutine, ‘Step Over’ will execute the subroutine and automatically move to the next line after the call. Conversely, ‘Step Into’ will allow the user to manually step through each instruction in the subroutine before returning to the line after the call. 4.9 4.10 3 4.11 Step Out Once the PC is in a subroutine, rather than manually stepping through each instruction, ‘Step Out’ will automatically run each instruction in the subroutine then return to the line after the call. Procedure 5 Going through window tabs Item Name Comments Dashboard Window located in the bottom left of the screen. Contains information about hardware such as device information (PIC18F87J11), configuration settings for the hardware, compiler toolchain, total memory, simulation settings, and Debugging resources. Navigator The second tab in this corner contains a list of all the subroutines in the program. You can click on these to jump to them in the code. Variables Contains the same variables and file registers that are listed in the watches window. It also shows the same information about each watch (Name, Type, Address, and Value). The difference is that this window provides an option to show only variables used near PC location. Watches A custom list of variables, file registers, locations in memory and subroutines that can be monitored during the debugging process in terms of location, and value. Breakpoints Shows a list of the breakpoints and their location. From this window you can create different types of breakpoints such as: line, data, address, and function. IO View List of various peripherals associated with the microcontroller. The second window displays a list of the associated peripherals corresponding to the selected device along with their address, value and addressable bits. Some examples include: A/D converter, Port A-J, Timer 1-4. If PORTD is selected, the second window will show the address, value and bits associated with LATD, PORTD and TRISD. Program Memory This window displays the Address, Opcode, Label, and assembly code associated with each line in the program. This is useful for observing which instruction the PC is on. Variables are translated into their corresponding location in memory. File Registers This window displays an array of each location in memory and the values. By hovering over the boxes with the cursor, the corresponding file register and location will be shown. SFRs This window shows a list of each SFR. The list contains the name, address, hex value, and binary value within each SFR. Configuration Bits This window shows a list of all the configurable bits for the specific microcontroller. The only one used in this lab is the XINST (extended instruction set) which is configured as off. In this window the user can manually toggle the values for these bits in addition to the code. Hardware Stack Keeps track of the return address for when the PC goes into a subroutine. 4 Procedure 6 Analysis of the program Purpose of The Program This program causes LEDs D8-D1 to turn on sequentially and then turn off sequentially in the reverse order. Specify device type (PIC18F87J11) Include the instructions for the device. Disable the extended instruction set. Assign addresses in memory for variables (delay_count1 and 2) Set the reset/interrupt vector (start location in memory) Initialize the pins (RB3-0, RD3-0) as output. Main Program: Main Procedures of The Codes Turn on each LED, starting from D1 to D8, with a slight pause between each LED tuning on. The subroutine delay_blink is used for the delay The delay works by making the microcontroller count down from FF to 0 twice. It occurs twice because it can’t be initialized to a value greater than FF. the time it takes for the program to call delay_blink, count down from FF to 0 twice, and return is the time between each LED turning on/off. Once all the LEDs are on, the initial procedure occurs in reverse where each LED is sequentially turned off starting with D8 and with the same delay. Each LED it turned on by setting (BSF) or by clearing (BCF) the specific bit in the register. For example: bsf PORTD, 0; this sets the value of the first bit in PORTD to 1, thus turning on the corresponding LED (D1). Procedure 7 Programming the Controller Procedure # Task 7.4 Download the Program to the Microcontroller Comments Under project properties, change the hardware tool from simulation to PICkit3. Make and program the device. 5 Procedure 8 Debugging the Program (PICkit3) Procedure # 8.2 Task Debug the program Comments From the dropdown arrow choose ‘Program Device for Debugging Main Project’ Run and test the program on the selected hardware. Procedure 9 Reading Memory Procedure # Function Comments 9.1 Read memory to a file Saved as a hex file. 9.3 Programmer to Go test Load the program into the PICkit3. From here, the PICkit3 can be used to program another board with the code. Self-check of Completion (to be filled by student) Item Completion (Yes/No/NA) UML activity diagram attached. Yes Codes with detailed comments given. Yes