Iowa State University

CPRE 288 Laboratory


Lab 8: ADC: Interfacing with IR Distance Measurement Sensor via A/D Conversion

Lecture - Lab Connection

In lecture, you have studied the use of analog to digital conversion. In this lab, you will use those hardware features to build a simple range finder.  This lab will have you explore configuration settings of the Tiva TM4C123GH6PM A/D conversion functionality.

Prelab

  • Read through this lab description. Think about the functionality. The ADC is a complex subsystem, although this lab uses a relatively small subset of functionality.
  • Review the readings assigned in preparation for Lab, including:
    • Textbook, Chapter 7, Section 7.5 (in concert with Chapter 13 of the Tiva datasheet as needed); don’t read everything, look for basic concepts and overviews first, browse sample code that uses DRA (Direct Register Access) interface and system header file and steps that describe how it works, etc.
    • Tiva TM4C123GH6PM datasheet section related to the ADC; don’t read everything, look for basic concepts and overviews first, ignore things that seem outside the scope of the lab (even if you realize you later need it, for now, ignore it, such as digital comparators, differential mode); browse steps given for initialization, sample sequencer configuration, etc.
    • Review the lecture slides that discuss the ADC registers.
    • Another resource that gives a nice overview and details of the ADC is Valvano and Yerraballi, Chapter 14: Analog to Digital Conversion, Embedded Systems: Introduction to ARM Cortex-M Microcontrollers, 2014 ( Chapter 14 )
  • Review the data sheet for the I/R distance sensor to grasp how it operates.
  • Draft the code. It might help to sketch your system. The code should be complete, but you don't have to compile or execute it before coming to the lab. Attempt to draft some code to show your TA.

Answer the following questions in preparation for the lab (refer to the ADC in the Tiva datasheet, textbook, and/or other resources as needed):

  1. Which GPIO registers should be configured for this lab? [2 points]
  2. Which A/D registers should be configured for this lab? [2 points]
  3. How will you do sample averaging? You could use a software of hardware approach [1 points]
  4. It is recommended that you Embedded Application use a polling approach to wait for the ADC to complete conversions. The ADCRIS register bits may be polled to wait for conversion-complete conditions without generating an interrupt (i.e., no interrupt is sent to the NVIC interrupt controller). Recall textbook Figure 5.8, and the local ADC device RIS and IM registers. Instead of polling, suppose you want an interrupt handler to process ADC conversions. Give the settings of the appropriate the NVIC, and ADC registers? [1 point – extra credit]

 

Reference Files

Download the following files to a single folder your U: drive (right-click and select 'Save Target As'. Alternatively, download the zipped folder at the bottom of the screen).

  • Timer.c/Timer.h: The file that contains the utility functions for the cyBOT platform.
  • lcd.c/lcd.h: The program file with a number of LCD functions.

Lab 8 Description

  • Lab 8 Manual: A detailed description of the objectives to complete for Lab 8

Cautions

Turn the power to the Cerebot board and iRobot off before charging. The Cerebot board consumes power and the battery will not charge if the robot is in full_mode (which it enters after calling oi_init, turing the power LED yellow). The robot is charging when the robot's power LED is pulsing red and both green LEDS on the dock are lit.

Reference Files

Files Description
Tiva TM4C123GH6P datasheet.pdf Information about the TM4C123GH6P
Documentation on printf Documentation for the lprintf and printf function.