Question: The sensor s output voltage can be digitized with one of the ADC channels in the MCU. The ADC has a maximum of 1 4
The sensors output voltage can be digitized with one of the ADC channels in the MCU. The ADC has a
maximum of bits of resolution, providing levels of voltage digitization. The reference voltage is
provided by the voltage reference module in the MCU. The module provides three selections of voltages:
and V For example, if V is used, the ADC provides a resolution of mV
The example project,
C:tisimplelinkmsppsdkexamples
ortosMSPEXPPRdriverlibadcsingle
conversionrepeattimerasourceccs illustrates how to set up various modules to do the timer triggering.
Basically, it sets up the A timer to count in Up mode and Compare register TACCR to generate a
pulse train to trigger an ADC sampling on the rising edge of a pulse.
Use the previous project and the example project, and adapt accordingly, to produce the same results in the
previous exercise. Note that the example project uses ADC input channel A but the temperature sensor
uses A Define the sampling frequency to use with following statement:
#define SAMPLINGFREQUENCY Sampling frequency in Hz
Compute the necessary parameters in the program based on this constant and the current frequency of the
system do not hardcode the system clock frequency or its period For more precise timing, use SMCLK
not ACLK for the timer module setup. The duty cycle of the pulse train is not important here. So use
something reasonable.
Do not enter sleep mode in the control loop in mainas it is done in the example project There is no
triggering action in the control loop because it is now all done by the timer. Since we are sampling at a much
higher rate than the rate to print to the console, the ISR can just update a global variable to contain the latest
digitized value, and the control loop just uses it when needed.
Before the control loop is entered, do a quick measurement on the sampling frequency to verify that the ADC
is indeed sampling at the desired rate. For example, we can measure how long it takes to collect samples
with the Timer timer. Print the measured frequency to the debug console. If the measurement is
implemented properly, the measured frequency should be very close to the defined macro
SAMPLINGFREQUENCY because the timing is all controlled by hardware; the error should be less than
Hz Note that there are two software tasks going on at the same time here. One is the ISR being
invoked periodically to update the global variable containing the latest digitized value, and the other is main
doing the measurement. In order to measure the sampling rate accurately, we need to pay attention to when
the digitization cycle starts or ends.
After the quick measurement is done, enter the forever control loop to show the digitized value and voltage
at a regular interval. Note that the display frequency in the control loop the foreground task is much lower
than the sampling the background task frequency.
Do not use the MAPInterruptenableSleepOnIsrExit call in your program as it is done in the example
project so that the control loop in main can continue to run after an interrupt is processed. Also do not use
MAPCSinitClockSignal as it will change SMCLK to a much lower value.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
