Lab8 - lab PDF

Title Lab8 - lab
Course Intro to Embedded Systems
Institution University of Illinois at Chicago
Pages 5
File Size 215.9 KB
File Type PDF
Total Downloads 9
Total Views 152

Summary

lab...


Description

Lab #8 Distance Measurement (Time Capture) ECE 266, Spring 2021 Weeks 10 & 11 (3/16 or 3/30, 3/18 or 4/1) Lab location: Online only Lab Times & TAs • • •

T"8:00am"-"9:50am,"Yang%Liu%" T"12:00pm"-"1:50pm,"Salih%Atici" R"8:00am"-"9:50am,"Yang%Liu"

Demo Due: The beginning of your lab in Week 12 (4/6 or 4/8) Submission Due: Friday, Week 12, 4/9, 11:59pm

Introduction This is a two-week lab. The goal of this lab is for you to gain programming experience with the Time Capture (also called Input Capture) hardware function of a generalpurpose timer module of Tiva C. In the Tiva C Datasheet, this hardware function is called Input Edge-Time Mode. The learning objectives are: • • •

To gain programming experience with a general-purpose timer module for Time Capture To learn how to use an ultrasonic ranger in an embedded system Exercise embedded systems programming with I/O register access (bonus part, due by the end of the semester).

Notes: • • • •



Make sure you do the prelab before the lab starts. There is no starter code for this lab except one program file for the bonus part. You will learn more details of Tiva C timers in class meetings. This lab will help you get the hand-on experience prior to the study. There is a bonus part in this lab. The bonus points can be used to make up for any points you may lose on the homework and labs, but not for the exams. Doing it may help you get a perfect grade on the homework and labs. It takes about 20-30 minutes to complete the bonus part of this lab. All the bonus parts from Labs 6-8 are due by your last lab session in Week 15.

Prelab •





Read “Tiva TM4C123GH6PM Microcontroller Data Sheet,” pages 704-709 (to the end of Sec. 13.3.2 introduction), section 11.3.2.4 on pages 714-715, and section 11.4.4 on page 724. The datasheet can be found under the “Resources” tab on BlackBoard. Scan (read through quickly) Ch. 30 “Timer” of “TivaWare Peripheral Driver Library User Guide”. The guide can be found under the “Resources” tab on BlackBoard. Read again, and this time carefully, the descriptions of the following functions in Ch. 30 “Timer” of the TivaWare User Guide. You will need to use all those functions. o TimerConfigure() o TimerControlEvent() o TimerEnable() o TimerIntStatus() o TimerIntClear() o TimerValueGet() Note: There is an example on page 558; however, that example is considerably different from what you will do in this lab.





Read carefully the descriptions of the following functions in Ch. 15 “GPIO” of the TivaWare User Guide. You will need to use those two functions. o GPIOPinTypeTimer() o GPIOPinConfigure(). Note: In this lab, you have to call this function to route a GPIO pin to a timer pin. Review the lab grading form (“Lab8GradeForm.docx”). This is about how your lab TA will grade your lab.

Background Time Capture (Input Capture) is a commonly used hardware function in embedded systems to process input waveforms. In Tiva C, this hardware function is implemented in the general-purpose timer modules (GPTM) and is called Input Edge Time Mode. Before you start on Part 1, read through the whole lab description, and then discuss with your partner(s) about the system development approach, identify things to do, and assign work to each person.

Part 0: Preparation One partner (with the help of partner): In your working directory, create a new folder named “Lab8”. In this lab, there is no template code provide (except for the bonus part). Instead, you may reuse program files from previous labs, including “seg7.h”, “seg7.c”,

“seg7digit.h”, and “seg7digit.asm”, and some main.c for “lab8_main.c”. Copy those files into the “Lab8” folder. Switch to CCS, create a new CCS project “Lab8” with an external reference to the “Lab8” folder. Remember to add the #include directory paths and the library file paths for TivaWare and Util libraries. Switch to GitHub Desktop, commit the changes to your local repository, then push the changes to your group’s GitHub repository. Check on https://github.com to make sure the changes have been pushed into your group’s repository. Other partner(s): Run GitHub Desktop. Pull the new changes from GitHub to your local repository. Check that Lab8/ and the new files appear in your working directory. Switch to CCS, create a new CCS project “Lab8” with an external reference to the “Lab8” folder. Remember to add the #include directory paths and the library file paths for TivaWare and Util libraries.

Part 1: Get Initial Reading First of all, review Lab8Slides.pdf before you proceed. Attach the ultrasonic ranger to Grove jumper J15. Find out which GPIO pin and which timer pin that the signal pin of the ranger is connected to. You can find the information in Tiva C Datasheet. Create new program files named “ranger.c”, “ranger_asm.asm”, and “ranger.h”. You may write two functions in C and in “ranger.c”: 1. A function that initializes the timer being used with the ultrasonic ranger. 2. A function that sends the start pulse to the ranger. It activates the ultrasonic ranger. You must write the following function in assembly and in “ranger_asm.asm”: 3. A function that 1) calls the second function to activate the ranger; 2) gets the times of the rising edge and the falling edge of the response pulse, 3) calculates the time difference, converts it to distance, and returns the result. The prototypes of those three functions should be put into “ranger.h”. Review slides 20, 21 and 22 of Lab8Slides.pdf very carefully. They are essentially the pseudo codes for those three functions. Then, revise your “lab8_main.c” such that it prints out the distance results on the CCS terminal continuously. The number should change when you move an object close to or away from the ranger. If you get stuck in this part for more than a few hours, contact your TAs or the instructor for help.

Part 2: Measure Distance with Two-Mode Display Make sure the 7-segment display is attached to the Grove base, Jumper J10. Revise your main.c so that your system works as the follows: • Pushbutton SW1 is used as a START/PUSE button. If a user pushes SW1, the system should become activated: It should show the distance of measurement continuously on the 7-segment display. If the user pushes SW1 again, the system should be de-activated; and pushes SW1 again, the system should be activated again. • Pushbutton SW2 is used to switch between two display modes: 1) a Millimeter mode that shows the distance in millimeters; and 2) an Inch mode that shows the distance in feet and inches. • In the Inch mode, the 7-segment display should show “xx:yy”, where xx is the number of feet and yy is the number of inches. There should be no leading zeros in either part. (You may have to revise your 7-segment display codes.) The colon should be turned on. • In the Millimeter mode, the 7-segment display should show the four digits of the distance in millimeters. If the distance is greater than 9,999 millimeters, it should show “9999”. There should be no leading zeros. The colon should be turned off. • Initially, when the system starts, it should be de-activated, put in the Inch mode, and show “ 0: 0” on the 7-segment display. Demo your system to your TA. If you can demo Part 2, you don’t have to demo Part 1.

Lab Submission Your group should write a lab report that includes the following: 1. Describe the responsibility of each person in your group, and estimate the breakdown of contribution in percentage (e.g. 50% and 50% for a two-person group, or 33.3%, 33.3% and 33.3% for a three-person group). Note: If one contributes 40% or higher in a two-person group or 25% or higher in a three-person group, he or she may receive the same grade as the group gets. 2. Describe how your code in Part 1 converts the number of clock cycles to the distance in millimeters. 3. Describe how your code in Part 2 implements the pushbutton functions. 4. How much flash memory does your program take? How much SRAM memory? 5. Estimate how many hours in total you and your partners have worked on this lab. Submit 1) a zip file named “Lab8.zip” for all the source code files in your Lab8 folder; and 2) your lab report on BlackBoard under Lab 8 assignment. Do NOT include nonsource code files in Lab8.zip. Make sure that you have pushed the latest version of your code into GitHub. This step is required for you to get the grade.

Bonus Part (25 Extra Points) The bonus part is due in your last lab session this semester. In the bonus part, re-write your function in “ranger_asm.asm” using direct I/O register access. No TivaWare functions should be called. This part requires significantly more effort. You should first complete Parts 1 and 2 (do not skip them). The bonus points do NOT overflow outside the combined lab and homework grade, i.e. you may not get over 100% on those two parts. Download “ranger_asm_direct.asm” from Lab 8 attachment into your “Lab8” folder and use it as the template. The file contains declarations of pointers to several Timer I/O registers. Those are all the I/O registers that you need to use. For the details of those I/O registers, read Tiva C Datasheet, Ch. 11, “General-Purpose Timers”. Check out Sec. 11.6, “Register Descriptions”.

Demo and Lab Submission for the Bonus Part Demo the new system to your TA. You must start from Build and show that you have excluded “ranger_asm.asm” from the Build and have included “ranger_asm_direct.asm” in the Build. If you have completed the bonus part, include “ranger_asm_direct.asm” in the “Lab8.zip” file. The file should be added in your GitHub repository and the latest version should be pushed....


Similar Free PDFs