<< Chapter < Page Chapter >> Page >

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 4, write a C language program turning your MSP430 LaunchPad into a simple 10 level voltmeter. 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. DO NOT EXCEED AN INPUT VOLTAGE OF 3.3V . You will damage your circuits and destroy your MSP430. 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 G2231 has one 12 channel 10 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 G2231, channels 1-8 are connected to the 8 P1 GPIO pins, and channel 10 is connected to the chip's internal temperature sensor. You can select which channel to convert by setting the ADC10CTL1 register's ( 10 bit ADC C on t ro l 1 ) INCH property ( In put Ch annel).

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 11 1111 1111 (0x03FF)
  • 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 01 1111 1111 (0x01FF)
  • The ADC will have a sample resolution of 3.3V/1024 [Voltage Range/2 #Bits ], or .0032 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).

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 10 is a peripheral, as well as the MSP430's UART (serial controller) and timers.

    Adc10 operation modes

  • Single Sample and Hold-- the ADC10 will start a conversion when triggered by the CPU. After that conversion, it will hold the converted value in the ADC10MEM register 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 ADC10 will convert a series of different channels once, and store the result to ADC10MEM.
  • Repeat Single Channel Mode-- it will continuously sample on channel, continuously updating the ADC10MEM register.
  • Repeat Sequence of Channels Mode-- the ADC will continuously sample through a series of channels.
The MSP430's ADC 10 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.

Questions & Answers

How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
scanning tunneling microscope
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
The nanotechnology is as new science, to scale nanometric
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
what school?
biomolecules are e building blocks of every organics and inorganic materials.
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
sciencedirect big data base
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
do you think it's worthwhile in the long term to study the effects and possibilities of nanotechnology on viral treatment?
Damian Reply
absolutely yes
how to know photocatalytic properties of tio2 nanoparticles...what to do now
Akash Reply
it is a goid question and i want to know the answer as well
characteristics of micro business
for teaching engĺish at school how nano technology help us
How can I make nanorobot?
Do somebody tell me a best nano engineering book for beginners?
s. Reply
there is no specific books for beginners but there is book called principle of nanotechnology
how can I make nanorobot?
what is fullerene does it is used to make bukky balls
Devang Reply
are you nano engineer ?
fullerene is a bucky ball aka Carbon 60 molecule. It was name by the architect Fuller. He design the geodesic dome. it resembles a soccer ball.
what is the actual application of fullerenes nowadays?
That is a great question Damian. best way to answer that question is to Google it. there are hundreds of applications for buck minister fullerenes, from medical to aerospace. you can also find plenty of research papers that will give you great detail on the potential applications of fullerenes.
what is the Synthesis, properties,and applications of carbon nano chemistry
Abhijith Reply
Mostly, they use nano carbon for electronics and for materials to be strengthened.
is Bucky paper clear?
carbon nanotubes has various application in fuel cells membrane, current research on cancer drug,and in electronics MEMS and NEMS etc
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Intro to computational engineering: elec 220 labs. OpenStax CNX. Mar 11, 2013 Download for free at http://cnx.org/content/col11405/1.2
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Intro to computational engineering: elec 220 labs' conversation and receive update notifications?