Uploaded by Stefan Bifolchi

Lab1 Records

advertisement
Records
Procedure 4 Debugging the program (Simulator)
Procedure #
Function
4.2
Set PC at Cursor
4.3
Run to Cursor
4.4
New Watch
4.5
Set Breakpoint
4.6
Reset
4.7
Finish Debugger
Session
4.8
Run with Pre-set
Breakpoint
4.9
Step Into
4.10
Step Over
4.11
Step Out
Procedure 5 Going through window tabs
Item Name
Dashboard
Navigator
Variables
Comments
PC = 0x4
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:
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 (WindowDebuggingWatches)
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)
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
The PC moves back to the start of the program which is location 0 in
memory.
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.
The breakpoint is still set. The PC stopped at the address location of
this instruction (0x14) and all the previous instructions were executed.
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.
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.
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.
Comments
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.
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.
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
Breakpoints
IO View
Program Memory
File Registers
SFRs
Configuration Bits
Hardware Stack
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.
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.
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.
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.
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.
This window shows a list of each SFR. The list contains the name, address, hex value,
and binary value within each SFR.
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.
Keeps track of the return address for when the PC goes into a subroutine.
Procedure 6 Analysis of the program
Purpose of The Program
Main Procedures of The
Codes
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:
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
Download the Program to the
7.4
Microcontroller
Procedure 8 Debugging the Program (PICkit3)
Comments
Under project properties, change the
hardware tool from simulation to PICkit3.
Make and program the device.
Procedure #
8.2
Task
Debug the program
Procedure 9 Reading Memory
Procedure #
Function
9.1
Read memory to a file
9.3
Comments
From the dropdown arrow choose ‘Program Device
for Debugging Main Project’
Run and test the program on the selected hardware.
Programmer to Go test
Comments
Saved as a hex file.
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
UML activity diagram attached.
Codes with detailed comments given.
Completion (Yes/No/NA)
Yes
Yes
Download