Lab5 Zybo Xilinx
Lab5 Zybo Xilinx
Lab5 Zybo Xilinx
Objectives
After completing this lab, you will be able to:
Utilize the CPUs private timer in polled mode
Use SDK Debugger to set break points and view the content of variables and memory
Procedure
This lab is separated into steps that consist of general overview statements that provide information on
the detailed instructions that follow. Follow these detailed instructions to progress through the lab.
This lab comprises 4 primary steps: Open the project in Vivado, create a SDK software project, verify
operation in hardware, and launch the debugger and debug the design.
Design Description
You will use the hardware design created in lab 4 to use CPUs private timer (see Figure 1). You will
develop the code to use it.
Step 2:
Create an
SDK
software
project
Step 3:
Verify
operation in
hardware
www.xilinx.com/support/university
[email protected]
copyright 2015 Xilinx
Step 4:
Launch
Debugger
ZYNQ 5-1
Lab Workbook
Step 1
Use the lab4 project from the last lab or, use the lab4 from the
{labsolutions} directory, and save it as lab5. Open the project in Vivado and
then export to SDK.
1-1-1. If you wish to continue using the design that you created in the previous lab, open the lab4 project
from the previous lab, or open the lab4 project in the {labsolutions} directory, and Save it as lab5
to the {labs} directory
Since we will be using the private timer of the CPU, which is always present, we dont need to
modify the hardware design.
1-1-2. Open the Block Design. You may notice that the status changes to synthesis and implementation
out-of-date as the project was saved as. Since the bitstream is already generated and will be in
the exported directory, we can safely ignore any warning about this.
1-1-3. In Vivado, select File > Launch SDK
A warning pop-up window indicating that the design is out of date. Since we have not made any
changes, we can ignore this.
1-1-4. Click Yes.
Step 2
2-1-1. In the Project Explorer in SDK, right click on lab4, lab4_bsp and system_wrapper_hw_platfrom_2
and select Close Project
2-1-2. Select File > New > Application Project.
2-1-3. Name the project lab5, and for the board Support Package, (Leave Create New for the Board
Support Package) and click Next.
2-1-4. Select Empty Application and click Finish.
2-1-5. Select lab5 > src in the project explorer, right-click, and select Import.
ZYNQ 5-2
www.xilinx.com/support/university
[email protected]
copyright 2015 Xilinx
Lab Workbook
2-2.
2-3.
www.xilinx.com/support/university
[email protected]
copyright 2015 Xilinx
ZYNQ 5-3
Lab Workbook
2-3-1. In SDK, in the Problems tab, double-click on the unknown type name x for the parse error. This
will open the source file and bring you around to the error place.
XScuTimer_LookupConfig( )
XScuTimer_CfgInitialize( )
XScuTimer_LoadTimer( )
XScuTimer_EnableAutoReload( )
XScuTimer_Start( )
2-3-5. Scroll down the file further and notice that there are few more lines intentionally left blank with
some guiding comments.
ZYNQ 5-4
www.xilinx.com/support/university
[email protected]
copyright 2015 Xilinx
Lab Workbook
XScuTimer_LoadTimer( )
XScuTimer_ClearInterruptStatus ( )
LED_IP_mWriteReg ( )
2-3-6. Using the API functions list, complete those lines. Save the file and correct errors if necessary.
www.xilinx.com/support/university
[email protected]
copyright 2015 Xilinx
ZYNQ 5-5
Lab Workbook
Step 3
Connect the board with micro-usb cable(s) and power it ON. Establish the
serial communication using SDKs Terminal tab.
3-1-1. Make sure that micro-USB cable(s) is(are) connected between the board and the PC. Turn ON
the power
3-1-2. Select the
tab. If it is not visible then select Window > Show view > Terminal.
ZYNQ 5-6
www.xilinx.com/support/university
[email protected]
copyright 2015 Xilinx
Lab Workbook
3-1-3. Click on
and if required, select appropriate COM port (depends on your computer), and
configure it with the parameters as shown. (These settings may have been saved from previous
lab).
3-2.
Program the FPGA by selecting Xilinx Tools > Program FPGA and
assigning system_wrapper.bit file. Run the TestApp application and verify
the functionality.
Launch Debugger
4-1.
Step 4
4-1-1. Right-click on the Lab5 project in the Project Explorer view and select Debug As > Launch on
Hardware (GDB).
The lab5.elf file will be downloaded and if prompted, click Yes to stop the current execution of the
program.
4-1-2. Click Yes if prompted to change to the Debug perspective.
At this point you could have added global variables by right clicking in the Variables tab and
selecting Add Global Variables All global variables would have been displayed and you could
have selected desired variables. Since we do not have any global variables, we wont do it.
4-1-3. Double-click in the left margin to set a breakpoint on various lines in lab5.c shown below. A
breakpoint has been set when a tick and blue circle appear in the left margin beside the line
when the breakpoint was set. (The line numbers may be slightly different in your file.)
The first breakpoint is where count is initialized to 0. The second breakpoint is to catch if the
timer initialization fails. The third breakpoint is when the program is about to read the dip switch
settings. The fourth breakpoint is when the program is about to terminate due to pressing of
center push button. The fifth breakpoint is when the timer has expired and about to write to LED.
www.xilinx.com/support/university
[email protected]
copyright 2015 Xilinx
ZYNQ 5-7
Lab Workbook
In the Variables tab you will notice that the count variable may have value other than 0.
4-1-5. Click on the Step Over (
) button or press F6 to execute one statement. As you do step over,
you will notice that the count variable value changed to 0.
ZYNQ 5-8
www.xilinx.com/support/university
[email protected]
copyright 2015 Xilinx
Lab Workbook
4-1-6. Click on the Resume button again and you will see that several lines of the code are executed
and the execution is suspended at the third breakpoint. The second breakpoint is skipped. This is
due to successful timer initialization.
4-1-7. Click on the Step Over (F6) button to execute one statement. As you do step over, you will notice
that the dip_check_prev variable value changed to a value depending on the switch settings on
your board.
4-1-8. Click on the memory tab. If you do not see it, go to Window > Show View > Memory.
4-1-9. Click the
www.xilinx.com/support/university
[email protected]
copyright 2015 Xilinx
ZYNQ 5-9
Lab Workbook
4-1-12. Click on the Resume button to continue execution of the program. The program will stop at the
writing to the LED port (skipping fourth breakpoint as center push button as has not occurred).
Notice that the value of the counter register is changed from the previous one as the timer was
started and the countdown had begun.
4-1-13. Click on the Step Over button to execute one statement which will write to the LED port and
which should turn OFF the LEDs as the count=0.
4-1-14. Double-click on the fifth breakpoint, the one that writes to the LED port, so the program can
execute freely.
4-1-15. Click on the Resume button to continue execution of the program. This time it will continuously
run the program changing LED lit pattern at the switch setting rate.
4-1-16. Flip the switches to change the delay and observe the effect.
4-1-17. Press a push button and observe that the program suspends at the fourth breakpoint. The timer
register content as well as the control register (offset 0x08) is red as the counter value had
changed and the control register value changed due to timer stop function call. (In the Memory
monitor, you may need to right click on the address that is being monitored and click Reset to
refresh the memory view.)
4-1-18. Terminate the session by clicking on the Terminate (
) button.
Conclusion
This lab led you through developing software that utilized CPUs private timer. You studied the API
documentation, used the appropriate function calls and achieved the desired functionality. You verified
the functionality in hardware. Additionally, you used the SDK debugger to view the content of variables
and memory, and stepped through various part of the code.
ZYNQ 5-10
www.xilinx.com/support/university
[email protected]
copyright 2015 Xilinx