Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ITU Control & Automation Eng. Dept. KON 3 0 9 E Microcontroller Systems Experiment 4 : ADC and USART Construct the circuit as shown in
ITU Control & Automation Eng. Dept.
KONE Microcontroller Systems
Experiment : ADC and USART
Construct the circuit as shown in the Figure.
Check your wiring and make sure that
no connection is made to the V supply.
The ADC peripheral should be configured to
sample CH and CH using Sequence A
The serial port USART should be configured
for a baud rate of and as a serial
terminal.
Write a program that will do the following
in the main loop:
Prints out a message such as: "Press a key to start conversion."
Starts the ADC Sequence A when a key is pressed from the PC keyboard
Waits until one conversion on Sequence A is complete.
Converts the results to voltages on the two channels using the reference
voltage of VDetermine the resolution of the ADC by consulting the reference
manual. Use an intt and represent the voltage in millivolts, as the terminal
program cannot print floating point numbers.
Prints out the result of the conversion in the format :
"ADCxxxx mV ADCyyyy mV
Repeat.
Remember that the terminal program in the PC must also be set to the same
baud rate as Alakart. Otherwise, garbled output, or even, no output will be
seen.
Aim: Using the USART to report periodic analog voltage samples to the PC
In this experiment, we will take sequence samples from the analog to digital
converter on two channels, and report the values back to the PC
For this experiment, you will need to consult the usual reference documents:
LPC user manual
LPCx datasheet
Alakart schematic diagram
Write the code using the peripheral support libraries Xpressso SDK or direct
register programming or a combination of both.
PART I
Write in your report:
What values must be written to which registers so that ADC Sequence A
can be configured to sample CH and CH
How the serial port is set to Baud.
The frequencies of "main clock" and "system clock" by checking the
configuration functions. Write which functions you check and how you find
the result.
Store the code for this part in a folder named EXPART
In PART I, we built an analog to digital converter that samples Sequence A once
when a key is pressed on your keyboard. In PART II we will make the sampling
triggered by the SCT timer peripheral, in hardware and get the result using an
INT. This is typically how it is implemented in consumer products.
Keep the same circuit as in PART I but add a LED to a suitable PIO pin with a
resistor. This time the following peripherals must be set:
ADC as in PART I with "Sequence A set to sample ADC and ADC
However, the ADC must be configured to be triggered from SCT OUT
Serial port USART terminal as in PART I, but with Baud rate Baud.
SCT set as an event generator and its output changes at end of count
event. The duration of SCT must be calculated and set so that the ADC is
triggered every ms Remember that system clock is configured to
MHz in the projects provided with the serial port examples and not
MHz
ADC conversion complete" INT is enabled and configured.
PIO is configured such that the pin where the LED is connected is an
output and the LED is turned OFF.
Write a program that will do the following:
ADC Sequence A is triggered for conversion by the SCT timer every
ms for conversion sequences second
At the completion of the ADC sequence, an end of conversion INT is
triggered.
Within the ISR: ADC results are stored in a structure, a global volatile
variable is set to True and the LED is toggled.
Within the main loop of the program: The global variable is repetitively
queried checked to see if it has been set to True by the ISR. If it has been
set to True, then: The ADC results are converted to actual voltages in mV
PART II
and printed in the same format as in PART I, and very important!: the
global variable is set back to False.
As a result, when the program is ran, we should see the LED flashing at s and
the result of the conversion appears on the screen in millivots every ms
Note that the conversion result is retrieved from the ADC within the ISR, but it is
printed out in the main loop. The ISR must signal the main loop that the
conversion is complete using a global variable that is called a "flag".
Use a chronometer to check that you really get the correct timing. Time
blinks and make sure it is close to s
Write in your report:
How the SCT is configured so that it can trigger the ADC every ms
Provide the equation for the calculation by consulting the reference manual.
What values must be written to which registers?
Where is the INT vector defined? Write the name of the file and copy the line
where it is defined, to your report
Describe your program and show how each software function and hardware
peripheral interacts with the others.
Store the code for this part in a folder named EXPART
This i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started