<< Chapter < Page Chapter >> Page >
Updated references to work with the ADC12 and the ESCAPE platform

The c language and analog interfacing: your task

This lab covers the basic principals behind Analog to Digital Conversion, as well as the basics of programming in C. You are expected to have some background in C from class, but if you are confused, see this basic reference .

  1. Using Code Composer Studio 5, write a C language program turning your ESCAPE Platform into a simple 10 level light meter. Your program should divide the 0-3.3V input range of the ADC into 10 zones, and then output from a 0 to a 9 on the LED display depending on the input voltage. IN GENERAL, DO NOT EXCEED AN INPUT VOLTAGE OF 3.3V (You don't have to worry about this during this light sensor lab). You will damage your circuits and destroy your MSP430 if you measure a raw voltage greater than 3.3V though. Assignment Details

The adc and "c" through a practical example

Interfacing with the analog world: the adc

ADC's play an incredibly important role in digital electronics and DSP. ADC stands for A nalog to D igital C onverter, and it does exactly what you would expect it to. It samples an external voltage, and then converts that voltage to a binary number compared to the reference voltage range from Vdd to Vss. (In plain English terms, the ADC samples what fraction the input is of some maximum allowed reference voltage.) The ADC's result gets written to a memory mapped register, where the programmer can access it and use it in his or her code.

An ADC has a finite voltage range it can safely convert (usually related to its power supply range, but not always). The precision of the converted sample is related to the number of bits used by the ADC. More bits means more precision (more finite "slots" into which the infinitely variable analog single can be quantized) and a lower "quantization error." To learn more about error and ADC, see this except from the Introduction to Electrical Engineering course notes . ADC's also have a maximum sampling rate specification (how frequently the ADC can make a conversion), but in this course we will be sampling very low frequency signals, so we won't need to worry about it.

The msp430 adc

The MSP430 F5637 has one 16 channel 12 bit 200Khz ADC. ADC channels allow the single ADC to select between several different signals (such as two different analog inputs on different GPIO pins) like an analog multiplexer. In the F5637, channels 1-8 are connected to the 8 P6 GPIO pins, and channel 10 is connected to the chip's internal temperature sensor.

For this lab, we will configure the ADC to use the internal 3.3 Vdd as the reference voltage.

  • A voltage of 3.3V would result in the ADC register holding 1111 1111 1111 (0x0FFF)
  • A voltage of 0.0V would result in the ADC register reading 00 0000 0000 (0x0000)
  • A voltage of 1.65V would result in the ADC register reading 0111 1111 1111 (0x07FF)
  • The ADC will have a sample resolution of 3.3V/4096 [Voltage Range/2 #Bits ], or .00081 Volts.

The ADC is a peripheral device, so it operates independently from the CPU. It has several operation modes (configured by writing to its control registers).

Peripheral
A device that can operate independently from direct CPU support and control. Peripherals often rely on interrupts to notify the CPU when they have completed some given task or need attention, and use independent control registers for configuration. The ADC 12 is a peripheral, as well as the MSP430's UART (serial controller) and timers.

    Adc12 operation modes

  • Single Sample and Hold-- the ADC12 will start a conversion when triggered by the CPU. After that conversion, it will hold the converted value in the ADC12MEMx registers and automatically go into sleep mode until signaled to begin another conversion. We will mostly use this mode.
  • Sequence of Channels Sample and Hold-- the ADC12 will convert a series of different channels once, and store the result to ADC12MEM.
  • Repeat Single Channel Mode-- it will continuously sample on channel, continuously updating the ADC12MEM register.
  • Repeat Sequence of Channels Mode-- the ADC will continuously sample through a series of channels.
The MSP430's ADC 12 also has a built in memory controller. We won't be using it, but it becomes important when using the repeat modes. The memory controller can automatically write the ADC data into main memory as conversions finish, bypassing the CPU.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Elec 220 lab course (escape). OpenStax CNX. Apr 07, 2013 Download for free at http://cnx.org/content/col11513/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Elec 220 lab course (escape)' conversation and receive update notifications?

Ask