ECE 3710 Lab 1 solution

$19.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Objectives
The student should become familiar with the process of building, downloading, debugging and
running programs on a microcontroller using an IDE.
Overview
In this lab we will be running our first assembly program on the microcontroller and de-bugging another
program that copies data in a couple ways. All assembly programs may be found on the course wiki
found at:
https://spaces.usu.edu
under code link in the Labs section.
Preparation
1. Come to lab with your Tiva C Launchpad board and its USB cable.
2. Be prepared to use most of the instructions you have learned in class.
3. Read V1.Ch2.3—7 and V2.Ch1.3
4. Read through the two Keil uVision tutorials from Circuits Today posted on the wiki at
https://spaces.usu.edu/display/ece3710/code_examples.
Procedure
1 Setup Blinky
A. Download a blank TM4CGH6PM_ASM project form the course wiki, Supplementary material for
lab page.
B. Download the Lab1 code from the wiki and unzip the folder. There you will find blinky.asm. Use
it to replace the main.s in the TM4CGH6PM_ASM folder.
C. Open the SP project.
D. On the left panel will be main.s under Source Group 1. Right click on main.s and remove it. Right
click on Source Group 1, and add existing files to group. Add your blinky.asm file (may have to
change Files of type: drop menu to see .asm files).
E. From the menu, select Project – Build Target. As long as there weren’t any errors, your project
is ready to run!
2 Running Blinky on Your Board
You will be using the onboard debugger to download code to and receive diagnostics from your board.
The software drivers should already be installed on your host PC. If not, notify your TA.
A. Select Debug – Start/Stop Debug Session and your debugger will automatically launch. In the
debugger you have access to all of the memory on your device. You can step through the code
using F10/F11 or you can let it run by pressing F5.
B. Select View – System Viewer – GPIO – GPIOF. This is the port which the LEDs on your physical
board are hooked up to. In the GPIOF window, look at the DATA register. This is where your
microcontroller will actually assert the pins which make the LEDs turn on and off. Pin 1 is
mapped to the red LED on your board.
C. Press F5 to run your program if you haven’t already. Note the changing port pins. Step through
the assembly code and see if you can understand what is happening. HINT: Section ten of the
Tiva™ C Series TM4C123GH6PM Microcontroller Data Sheet on the wiki may prove helpful.
D. As the last step in this section, use the logic analyzer to measure the frequency of the LED
blinking, and modify Blinky.asm so your board blinks twice as fast. Refer to the Tiva C Series
TM4C123G LaunchPad Evaluation Board User’s Guide on the course wiki to obtain pinout
information for the red LED light. Show the verification from the logic analyzer to your TA.
NOTE: Do not connect your board to the logic analyzer without prior authorization from your
TA. If connected incorrectly, there is a very good chance that you will fry your board!
E. For your report, include a screen capture of the timing before and after the code edits. Use the
logic analyzer to obtain this information.
3 Commenting Code
The Blinky code functions but is missing some important information. Fully describe the function
through comments. Clarity through commenting will simplify the debugging progress throughout your
career. Your freshly commented code will be part of the lab report.
4 Running Blinky Using the Simulator
It isn’t always practical to use/have a physical board for debugging purposes. Keil uVision is capable of
simulating certain boards so that we can write and debug programs and then transfer them to a board
later and know that they’ll work. Unfortunately, the Tiva C isn’t yet emulated in the Keil software, so
we’ll have to simulate a very similar board, the TI LM3S1968.
A. Download the blank LM3S1968_ASM project from the Code examples page of the wiki.
B. Use the blinky.asm file to populate the empty project.
C. Build the project.
D. Now select Debug – Start/Stop Debug Session and your debugger will automatically launch for
the simulated board. You can step through the program and examine registers/memory just as
you would for a real board.
5 Code Debugging
Now it’s your turn to fix some code. Now copy the file hello_students.asm from the wiki and set this up
the same way you set up Blinky in an LM3S1968 project. This program copies a message “Hello
Students!” from read-only memory to a location in SRAM above the memory reserved for the stack.
However, there are bugs in the code which keep the program from functioning normally. Use the
simulator to step through the code and figure out what’s going on. For example, where is the message
located in memory and where is it being written? The memory tab (lower left hand corner) gives a view
of the device’s memory. Once you find and correct the bugs, demonstrate to the TA that your program
functions properly—i.e. you need to demonstrate that message is being written to memory correctly
and explain what’s going on.
If you have time, please see the discussion page for lab one on the wiki for changes you should make to
the program to gain some practice with assembly.
6 Logic Analyzer
Using the logic analyzer to verify a bit stream is a very valuable skill. The objective of this exercise is to
teach you to capture data by triggering on a bit pattern. Read “Trigger Setup” (p. 87—93) in the
MDO3000 Series Mixed Domain Oscilloscopes User Manual (on the course wiki under Supplementary
material for lab)
1. Download a blank TM4CGH6PM_C project form the course wiki, Supplementary material for lab
page. (This is a C project, not ASM like before)
2. Replace main.c in the blank project with the logic_analyzer.c provided.
3. The logic analyzer file writes 8-bit parallel data on pins PE0 –PE3 and PC4-PC7, with PE0 as the
least significant bit (LSB) and PC7 as the most significant bit (MSB). PA7 is the clock. Connect the
logic analyzer to these pins, using port 8 to connect to the clock. Verify your method with your
TA before connecting.
4. Modify Bus1 to match this configuration (Refer to Section “Setting Up a Serial or Parallel Bus” (p.
67) of the oscilloscope user manual to help you do this). The data is clocked, on the positive
edge of the clock.
5. On the Trigger menu, define trigger type to be Bus
6. Use the Data tab in the Trigger menu to begin storing data after receiving ASCII character \n
(0x0A).
7. Run this configuration to capture the encoded message. The message will repeat infinitely, and
ends with the \n character.
8. Include the bit stream in your report. Use the bit stream to decode the ASCII message.
7 Report
In your lab report remember to talk about what you learned about code structure and how to debug
assembly. Include all code and images from the lab.