Analog-to-Digital Converter

Similar documents
SPI Serial Communication and Nokia 5110 LCD Screen

Hello and welcome to this presentation of the STM32L4 Analog-to-Digital Converter block. It will cover the main features of this block, which is used

Data Conversion and Lab (17.368) Fall Lecture Outline

Analog to Digital Conversion

EE251: Thursday October 11

Laboratory Exercise 4

Experiment # 4 Counters and Logic Analyzer

MODULAR DIGITAL ELECTRONICS TRAINING SYSTEM

Analog-to-Digital Conversion (Part 2) Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff

Section bit Analog-to-Digital Converter (ADC)

NORTHWESTERN UNIVERSITY TECHNOLOGICAL INSTITUTE

Point System (for instructor and TA use only)

Scans and encodes up to a 64-key keyboard. DB 1 DB 2 DB 3 DB 4 DB 5 DB 6 DB 7 V SS. display information.

Implementing a Rudimentary Oscilloscope

TXZ Family. Reference Manual 12-bit Analog to Digital Converter (ADC-A) 32-bit RISC Microcontroller. Revision

Hello and welcome to this training module for the STM32L4 Liquid Crystal Display (LCD) controller. This controller can be used in a wide range of

Review : 2 Release Date : 2019 Last Amendment : 2013 Course Code : SKEE 2742 Procedure Number : PK-UTM-FKE-(0)-10

Experiment # 9. Clock generator circuits & Counters. Digital Design LAB

7 SEGMENT LED DISPLAY KIT

ADC Peripheral in Microcontrollers. Petr Cesak, Jan Fischer, Jaroslav Roztocil

Chapter 11 Sections 1 3 Dr. Iyad Jafar

The 9S12 A/D converter Huang Section ATD_10B8C Block User Guide

Lab #6: Combinational Circuits Design

CPE 310L EMBEDDED SYSTEM DESIGN (CPE)

Design and Implementation of Timer, GPIO, and 7-segment Peripherals

Introduction to Mechatronics. Fall Instructor: Professor Charles Ume. Analog to Digital Converter

ECE251 Intro to Microprocessors Final Exam December 14, 2015, 2 p.m.

AN919: Using the EFM8LB1 ADC

AI-1616L-LPE. Features. High-precision Analog input board (Low Profile size) for PCI Express AI-1616L-LPE 1. Ver.1.02 Ver.1.01

RF4432 wireless transceiver module

Decade Counters Mod-5 counter: Decade Counter:

LCD Triplex Drive with COP820CJ

Interfacing Analog to Digital Data Converters. A/D D/A Converter 1

CM1-AD08V 0~5V, 1~5V, -10~10V, 0~10V An input signal is converted to a digital value from 0 to or from 8000 to 8000.

PHYSICS 5620 LAB 9 Basic Digital Circuits and Flip-Flops

Vorne Industries. 2000B Series Buffered Display Users Manual Industrial Drive Itasca, IL (630) Telefax (630)

Section Bit ADC with 4 Simultaneous Conversions

The Successive Approximation Converter Concept - 8 Bit, 5 Volt Example

Experiment: FPGA Design with Verilog (Part 4)

LAX_x Logic Analyzer

Simple PICTIC Commands

The Micropython Microcontroller

UNIT V 8051 Microcontroller based Systems Design

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT /12/14 BIT 10 TO 65 MSPS DUAL ADC

SWITCH: Microcontroller Touch-switch Design & Test (Part 2)

DT9834 Series High-Performance Multifunction USB Data Acquisition Modules

AI-1664LAX-USB. Features. 100KSPS 16-bit Analog Input Unit for USB AI-1664LAX-USB 1. Ver.1.01

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT /12/14 BIT 10 TO 105 MSPS ADC

Fig. 1 Analog pins of Arduino Mega

Lab #10 Hexadecimal-to-Seven-Segment Decoder, 4-bit Adder-Subtractor and Shift Register. Fall 2017

Programmable Logic Design Techniques II

TV Synchronism Generation with PIC Microcontroller

ASNT_PRBS20B_1 18Gbps PRBS7/15 Generator Featuring Jitter Insertion, Selectable Sync, and Output Amplitude Control

University of Illinois at Urbana-Champaign

Introduction to Embedded Microcomputer Systems Lecture Discrete digital signal. Continuous analog signal

AI-1204Z-PCI. Features. 10MSPS, 12-bit Analog Input Board for PCI AI-1204Z-PCI 1. Ver.1.04

BASCOM-TV. TV Code Features: ICs supported: BASCOM versions:

AN3023 Application note

NI-DAQmx Device Considerations

EE 367 Lab Part 1: Sequential Logic

Laboratory 7. Lab 7. Digital Circuits - Logic and Latching

S6B CH SEGMENT DRIVER FOR DOT MATRIX LCD

LCD MODULE DEM B SYH

SignalTap Plus System Analyzer

ES /2 digit with LCD

Tutorial on Technical and Performance Benefits of AD719x Family

Design and Implementation of an AHB VGA Peripheral

Digital Fundamentals. Lab 5 Latches & Flip-Flops CETT Name: Date:

DX-10 tm Digital Interface User s Guide

RF4432F27 wireless transceiver module

Logic Devices for Interfacing, The 8085 MPU Lecture 4

DIGITAL ELECTRONICS MCQs

AD16-64(LPCI)LA. Non-isolated high precision analog input board for Low Profile PCI AD16-64(LPCI)LA 1. Ver.1.01

A MISSILE INSTRUMENTATION ENCODER

64CH SEGMENT DRIVER FOR DOT MATRIX LCD

Converting between Analog and Digital Domains

Chapter 9 MSI Logic Circuits

MIE 402: WORKSHOP ON DATA ACQUISITION AND SIGNAL PROCESSING Spring 2003

Laboratory 11. Required Components: Objectives. Introduction. Digital Displays and Logic (modified from lab text by Alciatore)

Oscilloscopes, logic analyzers ScopeLogicDAQ

Vorne Industries. 87/719 Analog Input Module User's Manual Industrial Drive Itasca, IL (630) Telefax (630)

WINTER 15 EXAMINATION Model Answer

Tutorial Introduction

Interfacing the TLC5510 Analog-to-Digital Converter to the

ECB DIGITAL ELECTRONICS PROJECT BASED LEARNING PROJECT REPORT ON 7 SEGMENT DIGITAL STOP WATCH USING DECODER

IMS B007 A transputer based graphics board

MC54/74F568 MC54/74F569 4-BIT BIDIRECTIONAL COUNTERS (WITH 3-STATE OUTPUTS) 4-BIT BIDIRECTIONAL COUNTERS (WITH 3-STATE OUTPUTS)

Unit 3: Parallel I/O and Handshaking for LCD Control

Digital Systems Laboratory 3 Counters & Registers Time 4 hours

Pivoting Object Tracking System

82C55A CHMOS PROGRAMMABLE PERIPHERAL INTERFACE

1 Terasic Inc. D8M-GPIO User Manual

DT3162. Ideal Applications Machine Vision Medical Imaging/Diagnostics Scientific Imaging

VIRTUAL INSTRUMENTATION

Slide 1. Flip-Flops. Cross-NOR SR flip-flop S R Q Q. hold reset set not used. Cross-NAND SR flip-flop S R Q Q. not used reset set hold 1 Q.

1. Convert the decimal number to binary, octal, and hexadecimal.

For Teacher's Use Only Q Total No. Marks. Q No Q No Q No

o The 9S12 has a 16-bit free-running counter to determine the time and event happens, and to make an event happen at a particular time

DM Segment Decoder/Driver/Latch with Constant Current Source Outputs

o The 9S12 has a 16-bit free-running counter to determine the time and event happens, and to make an event happen at a particular time

Transcription:

5 5.1 Objectives: The TM4C is equipped with an analog-to-digital (ATD) conversion system that samples an analog (continuous) signal at regular intervals and then converts each of these analog samples into its corresponding binary value using the successive approximation technique. While doing this lab, you will learn, How to program the TM4C ATD converter system. How to convert the binary results to BCD for display as text on the Termite terminal window. How to populate a message template in RAM with new values. 5.2 Related material to read: Chapter 20 of text; good for concepts but not our specific ATD converter. Valvano Volume 1, Section 10.4, Analog to Digital Conversion. TM4C Data Sheet, Chapter 13. The TM4C analog-to-digital (ATD) conversion system: The TM4C ATD conversion system consists of a 12-channel, 12-bit, multiplexed input analog-to-digital converter block. Like many peripherals, in order to use the ATD feature, you must first power up one of the ATD modules. To do this, we again use the Run Clock Gate Control register like in Lab 4, only this time for the ATD (RCGCADC at - 1 -

address 0x400F.E638). Set bit 0 of the RCGCADC register to 1 in order to use ATD module 0 (ADC0). Since the ATD module will need access to the external signal being sampled, a GPIO port must be configured to connect an external pin to the ATD. Therefore, we must also power up the GPIO peripheral just like in Lab 4 using the RCGCGPIO register. Each of the ATD input channels are associated with a pin on the board. For this lab, we will use pin PE3. Figure 5.1 shows the assignment of each channel. Figure 5.1: ATD channel pin assignments (Table 13-1 of the datasheet) Every sample, or sequence of samples, is controlled by a sequencer. There are 4 sequencers total that can control every channel. This allows for greater flexibility and ability to work for many applications. Each sequencer also has its own set of attributes that may make it better for one application than another. As seen in Figure 5.2, each sequencer will take a different number of samples, and has an equivalent size of FIFO buffer. The FIFO buffer is where the results of each sample is stored. Figure 5.2: ATD Sequencer list (Table 13-2 of the datasheet) Since this lab will be fairly straight forward in that there is only one signal to sample at a relatively slow sample rate, sequencer 3 (SS3) will work perfectly. 5.3 GPIO Setup As mentioned before, the ATD needs access to the outside world via the GPIO port, so it is a good idea to set this up first. We need to configure the GPIO port so that it can receive a signal (input), and then send that signal to the ATD for sampling. (Refer to Lab 4 or datasheet for a reminder of GPIO registers). After the RCGCGPIO register has been configured to enable port E (by setting bit 4), the Alternate Function register (AFSEL) will need to be set for pin 3. The Alternate Function register tells the TM4C that we will - 2 -

not be using PE3 as a simple on/off switch like we did in Lab 4. Instead, enabling the AFSEL register tells the TM4C that we would like to connect the associated pin with some other peripheral in the TM4C. Since we are using PE3 (pin 3 of port E), set bit 3 in the AFSEL register associated with port E. When using an alternate function, the next step is to configure the PCTL register to tell the TM4C which, of the many peripherals available, we would like to use as the alternate function. It can be seen in Figure 5.4, that writing 1-15 to one of the PCTL 4 bit groups will enable a specific alternate digital function. Writing zero the appropriate 4 bits enables the analog alternate function. (A full list of alternate functions per pin is provided in Table 23-5 of the datasheet.) Next, set the direction of PE3 to input by setting bit 3 to 0 in the DIR register. Since we will be measuring a continuous (analog) signal, we must enable analog on PE3 by setting bit 3 to 1 in the AMSEL register. Figure 5.3: The GPIO PCTL register Figure 5.4: Partial table of GPIO PCTL alternate function assignments - 3 -

5.4 ATD Setup The base address for the ADC0 configuration registers is 0x4003.8000, and the following configuration registers will be referenced by their offset instead of their full address. Changes to the ATD configuration should only be made while the ATD is disabled! Controlling the ATD is done by controlling its associated sequencer. The sequencers control when a sample should be taken, and which sequencer is activated is controlled by the ADC Active Sample Sequencer register (ADCACTSS, offset 0x000). For this lab we will be using sequencer 3, therefore, in order to disable sequencer 3, clear bit 3 of the ADCACTSS. Figure 5.5: The ADC Active Sample Sequencer register Next, we will use a polling method in order to know when a sample is ready. To do this we monitor the interrupt flags in the RIS register (seen later). However, in order to tell the TM4C to set flags in the RIS register, we must set the IE0 bit in the ADC Sample Sequence Control register (ADCSSCTL3, offset 0x0A4). (Note that we are using SSCTL3 because we are using sequencer 3.) We also need to set the END0 bit to tell the sequencer to stop sampling after one sample. This seems redundant since sequencer 3 only takes one sample, but it is required. Note, that if you were using a different sequencer that had the capability to take many samples, the appropriate SSCTL register is where you would specify the number of samples desired. Figure 5.5: ADC Sample Sequence Control 3 register The TM4C has the capability to trigger a sample based on a variety of signals. For instance, a sample can start on the edge of a square wave, by software, or from the timer - 4 -

module. Again, like the interrupts, the trigger to start an ATD conversion is sequencer specific. What triggers the sequencer is configured using the ADC Event Multiplexer Select register (ADCEMUX, offset 0x014). We will be triggering each sample in software for this lab, therefore, bits 15:12 need to be cleared. Figure 5.6: ADC Event Multiplexer Select register So far we have told the TM4C that we need to create an input through GPIO to be used to receive our signal to be sampled, we have told which ATD module and which sequencer to use. However, we have not told the ATD module which channel to use. To do this, clear bits 3:0 of the ADC Sample Sequence Input Multiplexer Select 0 register (ADCSSMUX3, offset 0x0A0) to select channel AIN0. Figure 5.7: ADC Sample Sequence Input Multiplexer Select 0 register ATD sampling rate is controlled by the ADC Peripheral Configuration register (ADCPC, offset 0xFC4). The ATD can sample at 125 kilo-samples per second (ksps), 250 ksps, 500 ksps, and 1 Mega-samples per second (Msps). Since we are triggering via software, and doing so on a relatively slow interval, we can choose a sample rate of 125 ksps. Set bits 3:0 to 0x01 in the ADCPC register to select 125 ksps. - 5 -

Figure 5.8: ADC Peripheral Configuration register The ATD system is now configured and can be enabled. Once enabled, (by setting bit 3 of the ADCACTSS register) the ATD system is ready to start sampling on your trigger. 5.5 Sampling Since we set the ATD module up to initiate a sample from a software trigger, the program needs to tell the ATD module (specifically, the sequencer we are using) to start sampling. This is done using the ADC Processor Sample Sequence Initiate register (ADCPSSI, offset 0x028). Bits 3:0 represent each sequencer. Since we are using sequencer 3, setting bit 3 to 1 tells the sequencer to start sampling. Figure 5.9: ADC Processor Sample Sequence register A sampling sequence will take a few clock cycles, so we have to monitor when the sequence is complete. The ADC Raw Interrupt Status register (ADCRIS, offset 0x004) contains flags corresponding to each sequencer (bits 3:0) that are set to 1 when a sequence has completed. In our case, checking bit 3 monitors if / when sequencer 3 is done sampling. - 6 -

Figure 5.10: ADC Raw Interrupt Status register Each sequencer stores its results in its own FIFO buffer register (ADCSSFIFOn). Address offset: ADCSSFIFO0 0x048 ADCSSFIFO1 0x068 ADCSSFIFO2 0x088 ADCSSFIFO3 0x0A8 Once sampling is complete on sequencer 3, the value of the oldest sample will be in ADC Sample Sequence Result FIFO 3 (ADCSSFIFO3, offset 0x0A8). Figure 5.11: ADC Sample Sequence Result FIFO n register The ADC lets us know a sample value is ready for us by setting the appropriate bit in the ISR, then it waits for us to load the sample from the FIFO register. Therefore, we need to tell the ADC we are ready for it to continue sampling. To do this, we set bit 3 (for sequencer 3) of the Interrupt Status and Clear Register (ADCISC, offset 0x00C). Figure 5.12: ADC Interrupt Status and Clear register - 7 -

5.6 Procedure: Before the lab, draw a flowchart of a program you will write to convert an analog input applied to pin PE3 to its digital value and output the results to Termite every 1s. This flowchart should show the method to convert the digital value from the ATD converter to a BCD representation to be used in the display. The results should be displayed following the format Signal: X.Y Volts. Show the value to the number of digits that approximate the resolution of the ATD system. Program the ATD conversion system on the board to convert the analog signal to a 12-bit number between 0x00 and 0xFFF. Then convert this number to a value between 0.0 3.3 Volts, represented as an ASCII string, including the decimal point. Use this ASCII value to populate the results string in RAM and print the string using OutStr. Test your software by connecting the ATD inputs to GND, to V DD, and then to the analog signal from the power supply, adjusting the power and observing the changing output voltage in Termite. Demo this to your TA. Questions: 1. If V RH = 3.3V, what digital value is returned when the ATD system converts the following voltage using 12-bit conversion? 3.0 V 0.0 V 2.5 V 1.5 V 3.5 V 2. What will be the digital value when the ATD system converts the above voltages using V RH = 3.25V? What is the conversion resolution for this case? From this digital value, what is the voltage estimate that would minimize the maximum error of the measurement/calculation, I.e. V min-max 5.7 Lab report: For the lab write-up, include 1. Your flowcharts that you wrote before the lab and your program. 2. A copy of your working.s files. 3. A brief discussion of the objectives of the lab and the procedures performed in the lab. 4. Answers to any questions in the discussion, procedure, or question sections of the lab. - 8 -